Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alice-i-cecile opened this issue Jan 18, 2024 · 2 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. C-feature-request Category: A feature request, i.e: not implemented / a PR. L-dead_code Lint: dead_code T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@alice-i-cecile
Copy link

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.

@alice-i-cecile alice-i-cecile added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. labels Jan 18, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 18, 2024
@Jules-Bertholet
Copy link
Contributor

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
Copy link
Member

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

@rustbot rustbot added C-feature-request Category: A feature request, i.e: not implemented / a PR. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 14, 2024
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. L-dead_code Lint: dead_code labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. C-feature-request Category: A feature request, i.e: not implemented / a PR. L-dead_code Lint: dead_code T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants