Open
Description
Code
pub mod original {
#[cfg(FALSE)]
pub mod gated {
pub fn foo() {}
}
}
pub mod reexport {
pub use super::original::*;
}
pub fn main() {
reexport::gated::foo();
// A direct reference produces the desired output.
//original::gated::foo();
}
Current output
error[E0433]: failed to resolve: could not find `gated` in `reexport`
--> <source>:14:15
|
14 | reexport::gated::foo();
| ^^^^^ could not find `gated` in `reexport`
Desired output
error[E0433]: failed to resolve: could not find `gated` in `reexport`
--> <source>:14:15
|
17 | reexport::gated::foo();
| ^^^^^ could not find `gated` in `reexport`
|
note: found an item that was configured out
--> <source>:3:13
|
3 | pub mod gated {
| ^^^^^
note: the item is gated here
--> <source>:2:5
|
2 | #[cfg(FALSE)]
| ^^^^^^^^^^^^^
Rationale and extra context
If an item in a cfg
gated module is directly referenced then the diagnostic will mention the gate. This does not happen if the gated module is re-exported through a glob import.
Rust Version
rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7
rustc 1.89.0-nightly (777d37277 2025-05-17)
binary: rustc
commit-hash: 777d372772aa3b39ba7273fcb8208a89f2ab0afd
commit-date: 2025-05-17
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.4
Anything else?
Compiler Explorer: https://godbolt.org/z/d3rr35G4T