rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.6k stars 12.74k forks source link

Allow `dead_code` lint to be configured to validate that all pub code is used within the workspace #120079

Open alice-i-cecile opened 10 months ago

alice-i-cecile commented 10 months ago

When this setting is true, dead_code would analyze an entire workspace, checking that all code is used somewhere in the workspace.

This is particularly useful in projects that have libraries (for compilation speed or modularity reasons) that are never intended to be published. In those cases, it's easy to accidentally forget to remove dead code, as pub library types and traits and functions and constants are exempted.

With the addition of workspace-level lint controls, this feels like it may actually be possible. #74970 is related, but only targets binary crates.

Jules-Bertholet commented 10 months ago

Lints fire when compiling particular crates. But in this case, the compiler can't know to fire the lint until a crate's workspace dependents are compiled, at which point the dependency crate's compilation process is already over. So it's not clear at what stage the lint could be emitted.

jieyouxu commented 9 months ago

@rustbot label +C-feature-request -needs-triage