Closed
Description
Code
#![deny(unreachable_pub)]
mod config {
pub struct AccessMode;
}
pub enum StorageConfig {
OnDisk(config::AccessMode),
}
Current output
Compiling playground v0.0.1 (/playground)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.50s
Desired output
error: unreachable `pub` item
--> src/lib.rs:4:5
|
4 | pub struct AccessMode;
| ---^^^^^^^^^^^^^^^^^^
| |
| help: consider restricting its visibility: `pub(crate)`
|
= help: or consider exporting it for use by other crates
Rationale and extra context
Changing StorageConfig to
pub struct StorageConfig(config::AccessMode);
produces the desired output, so this is a difference between a reference to a type from an enum variant and a reference to a type from a struct.
Other cases
The same occurs if the enum variant and struct are defined with a named field (`access_mode: config::AccessMode`)
Rust Version
rustc 1.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: x86_64-unknown-linux-gnu
release: 1.83.0
LLVM version: 19.1.1
Anything else?
No response