File tree 4 files changed +57
-2
lines changed
compiler/rustc_middle/src/ty
4 files changed +57
-2
lines changed Original file line number Diff line number Diff line change @@ -297,7 +297,10 @@ impl Visibility {
297
297
} else if restricted_id == tcx. parent_module_from_def_id ( def_id) . to_local_def_id ( ) {
298
298
"pub(self)" . to_string ( )
299
299
} else {
300
- format ! ( "pub({})" , tcx. item_name( restricted_id. to_def_id( ) ) )
300
+ format ! (
301
+ "pub(in crate{})" ,
302
+ tcx. def_path( restricted_id. to_def_id( ) ) . to_string_no_crate_verbose( )
303
+ )
301
304
}
302
305
}
303
306
ty:: Visibility :: Public => "pub" . to_string ( ) ,
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ warning: glob import doesn't reexport anything with visibility `pub` because no
62
62
LL | pub use super::*;
63
63
| ^^^^^^^^
64
64
|
65
- note: the most public imported item is `pub(a)`
65
+ note: the most public imported item is `pub(in crate:: a)`
66
66
--> $DIR/reexports.rs:11:17
67
67
|
68
68
LL | pub use super::*;
Original file line number Diff line number Diff line change
1
+ //@ check-pass
2
+
3
+ #![ allow( dead_code) ]
4
+
5
+ mod outer {
6
+ pub mod inner {
7
+ pub ( in crate :: outer) struct Foo ;
8
+ pub fn bar ( ) -> Foo {
9
+ //~^ WARNING type `Foo` is more private than the item `outer::inner::bar` [private_interfaces]
10
+ Foo
11
+ }
12
+ }
13
+
14
+ pub mod nested {
15
+ pub mod inner {
16
+ pub ( in crate :: outer:: nested) struct NestedFoo ;
17
+ pub fn bar ( ) -> NestedFoo {
18
+ //~^ WARNING type `NestedFoo` is more private than the item `nested::inner::bar` [private_interfaces]
19
+ NestedFoo
20
+ }
21
+ }
22
+ }
23
+ }
24
+
25
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ warning: type `Foo` is more private than the item `outer::inner::bar`
2
+ --> $DIR/pub-restricted-warning.rs:8:9
3
+ |
4
+ LL | pub fn bar() -> Foo {
5
+ | ^^^^^^^^^^^^^^^^^^^ function `outer::inner::bar` is reachable at visibility `pub(crate)`
6
+ |
7
+ note: but type `Foo` is only usable at visibility `pub(in crate::outer)`
8
+ --> $DIR/pub-restricted-warning.rs:7:9
9
+ |
10
+ LL | pub(in crate::outer) struct Foo;
11
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12
+ = note: `#[warn(private_interfaces)]` on by default
13
+
14
+ warning: type `NestedFoo` is more private than the item `nested::inner::bar`
15
+ --> $DIR/pub-restricted-warning.rs:17:13
16
+ |
17
+ LL | pub fn bar() -> NestedFoo {
18
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ function `nested::inner::bar` is reachable at visibility `pub(crate)`
19
+ |
20
+ note: but type `NestedFoo` is only usable at visibility `pub(in crate::outer::nested)`
21
+ --> $DIR/pub-restricted-warning.rs:16:13
22
+ |
23
+ LL | pub(in crate::outer::nested) struct NestedFoo;
24
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
25
+
26
+ warning: 2 warnings emitted
27
+
You can’t perform that action at this time.
0 commit comments