Correct warning message in restricted visibility
This commit is contained in:
parent
d2eadb7a94
commit
265b10fe2e
4 changed files with 57 additions and 2 deletions
|
|
@ -62,7 +62,7 @@ warning: glob import doesn't reexport anything with visibility `pub` because no
|
|||
LL | pub use super::*;
|
||||
| ^^^^^^^^
|
||||
|
|
||||
note: the most public imported item is `pub(a)`
|
||||
note: the most public imported item is `pub(in crate::a)`
|
||||
--> $DIR/reexports.rs:11:17
|
||||
|
|
||||
LL | pub use super::*;
|
||||
|
|
|
|||
25
tests/ui/pub/pub-restricted-warning.rs
Normal file
25
tests/ui/pub/pub-restricted-warning.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
//@ check-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
mod outer {
|
||||
pub mod inner {
|
||||
pub(in crate::outer) struct Foo;
|
||||
pub fn bar() -> Foo {
|
||||
//~^ WARNING type `Foo` is more private than the item `outer::inner::bar` [private_interfaces]
|
||||
Foo
|
||||
}
|
||||
}
|
||||
|
||||
pub mod nested {
|
||||
pub mod inner {
|
||||
pub(in crate::outer::nested) struct NestedFoo;
|
||||
pub fn bar() -> NestedFoo {
|
||||
//~^ WARNING type `NestedFoo` is more private than the item `nested::inner::bar` [private_interfaces]
|
||||
NestedFoo
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
27
tests/ui/pub/pub-restricted-warning.stderr
Normal file
27
tests/ui/pub/pub-restricted-warning.stderr
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
warning: type `Foo` is more private than the item `outer::inner::bar`
|
||||
--> $DIR/pub-restricted-warning.rs:8:9
|
||||
|
|
||||
LL | pub fn bar() -> Foo {
|
||||
| ^^^^^^^^^^^^^^^^^^^ function `outer::inner::bar` is reachable at visibility `pub(crate)`
|
||||
|
|
||||
note: but type `Foo` is only usable at visibility `pub(in crate::outer)`
|
||||
--> $DIR/pub-restricted-warning.rs:7:9
|
||||
|
|
||||
LL | pub(in crate::outer) struct Foo;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: `#[warn(private_interfaces)]` on by default
|
||||
|
||||
warning: type `NestedFoo` is more private than the item `nested::inner::bar`
|
||||
--> $DIR/pub-restricted-warning.rs:17:13
|
||||
|
|
||||
LL | pub fn bar() -> NestedFoo {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ function `nested::inner::bar` is reachable at visibility `pub(crate)`
|
||||
|
|
||||
note: but type `NestedFoo` is only usable at visibility `pub(in crate::outer::nested)`
|
||||
--> $DIR/pub-restricted-warning.rs:16:13
|
||||
|
|
||||
LL | pub(in crate::outer::nested) struct NestedFoo;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue