unreachable_pub
lint does not fire in the case of partial wildcard shadowing #111360
Open
Description
I tried this code:
#![deny(unreachable_pub)]
pub use berp::*;
// 1.
// use darp::Foo;
pub fn example() {
let _ = Foo;
}
pub mod berp {
pub struct Foo;
// 2.
// pub struct Bar;
impl Foo {
pub fn hah(&self) {}
pub fn hoh(&self) {}
}
}
pub mod darp {
pub struct Foo;
}
I expected to see this happen:
When I uncomment 1.
(but not 2.
) above, the lint correctly fires, and says:
error: unreachable `pub` item
--> /tmp/breaky/breaky/src/lib.rs:3:9
|
3 | pub use berp::*;
| --- ^^^^
| |
| help: consider restricting its visibility: `pub(crate)`
|
= help: or consider exporting it for use by other crates
note: the lint level is defined here
--> /tmp/breaky/breaky/src/lib.rs:1:8
|
1 | #[deny(unreachable_pub)]
| ^^^^^^^^^^^^^^^
When I uncomment 1.
AND 2.
above, the lint no longer fires, despite the export being shadowed (though - it is still otherwise reachable).
Compiling breaky v0.1.0 (/tmp/breaky/breaky)
Finished dev [unoptimized + debuginfo] target(s) in 0.06s
Meta
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.68.0 (2c8cc3432 2023-03-06)
Context from discussion on reddit, and other wildcard shadowing shenanigans
edit: made it #![deny(unreachable_pub)]
not #[deny(unreachable_pub)]