When adding pub to a binary crate, the item is excluded from dead_code analysis.
While this is the right behavior for libraries, it is silly (and frustrating), because binaries cannot be used as dependencies. Instead, you have to use pub(crate) everywhere, to ensure that dead code analysis works as planned.
Meta
Reproduced on rustc 1.79
When adding
pubto a binary crate, the item is excluded fromdead_codeanalysis.While this is the right behavior for libraries, it is silly (and frustrating), because binaries cannot be used as dependencies. Instead, you have to use
pub(crate)everywhere, to ensure that dead code analysis works as planned.Meta
Reproduced on
rustc 1.79