Closed
Description
Given code that looks like:
mod foo {
pub struct Bar;
pub struct Baz;
}
mod bar {
pub use foo::{Bar, Baz};
}
you get:
$ rustc +nightly src/lib.rs --crate-type lib -W rust_2018_idioms
warning: struct is never used: `Bar`
--> src/lib.rs:2:5
|
2 | pub struct Bar;
| ^^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default
warning: struct is never used: `Baz`
--> src/lib.rs:3:5
|
3 | pub struct Baz;
| ^^^^^^^^^^^^^^^
warning: unreachable `pub` item
--> src/lib.rs:2:5
|
2 | pub struct Bar;
| ---^^^^^^^^^^^^
| |
| help: consider restricting its visibility: `pub(crate)`
|
= note: `-W unreachable-pub` implied by `-W rust-2018-idioms`
= help: or consider exporting it for use by other crates
warning: unreachable `pub` item
--> src/lib.rs:3:5
|
3 | pub struct Baz;
| ---^^^^^^^^^^^^
| |
| help: consider restricting its visibility: `pub(crate)`
|
= help: or consider exporting it for use by other crates
warning: unreachable `pub` item
--> src/lib.rs:7:19
|
7 | pub use foo::{Bar, Baz};
| ^^^ help: consider restricting its visibility: `pub(crate)`
|
= help: or consider exporting it for use by other crates
warning: unreachable `pub` item
--> src/lib.rs:7:24
|
7 | pub use foo::{Bar, Baz};
| ^^^ help: consider restricting its visibility: `pub(crate)`
|
= help: or consider exporting it for use by other crates
which when auto-fixed by cargo fix
will produce:
mod foo {
pub(crate) struct Bar;
pub(crate) struct Baz;
}
mod bar {
pub use foo::{pub(crate), pub(crate)};
}
which fails to compile!
cc @Manishearth