Skip to content

Lint unused features#152164

Open
mu001999 wants to merge 6 commits intorust-lang:mainfrom
mu001999-contrib:lint/unused_features
Open

Lint unused features#152164
mu001999 wants to merge 6 commits intorust-lang:mainfrom
mu001999-contrib:lint/unused_features

Conversation

@mu001999
Copy link
Contributor

@mu001999 mu001999 commented Feb 5, 2026

View all comments

Fixes #44232
Fixes #151752


This PR records used features through query side effect, then reports unsued features finally.

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 5, 2026
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is neat! in the future, it would be easier to review if you split the rename into a separate commit from the change in behavior.

could you add some tests for this please?

View changes since this review

@mu001999 mu001999 force-pushed the lint/unused_features branch 2 times, most recently from cb9b84c to cd83e12 Compare February 5, 2026 15:31
@mu001999
Copy link
Contributor Author

mu001999 commented Feb 5, 2026

Initial implementation completed. I plan to add more tests and check whether features in rustc are reported as unused correctly or not.

@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the lint/unused_features branch from cd83e12 to 2945856 Compare February 6, 2026 00:38
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the lint/unused_features branch from 2945856 to 36c0a20 Compare February 6, 2026 01:00
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the lint/unused_features branch from 36c0a20 to 2ddaf82 Compare February 7, 2026 01:16
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the lint/unused_features branch from 2ddaf82 to fb08c95 Compare February 7, 2026 11:37
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the lint/unused_features branch from fb08c95 to 38aefe4 Compare February 7, 2026 12:45
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the lint/unused_features branch from 38aefe4 to 0cda8d4 Compare February 7, 2026 13:35
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the lint/unused_features branch from 0cda8d4 to 2d2577f Compare February 7, 2026 14:19
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the lint/unused_features branch from 2d2577f to b67632e Compare February 7, 2026 15:08
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@mu001999 mu001999 force-pushed the lint/unused_features branch 2 times, most recently from a940d65 to 435090a Compare February 8, 2026 02:11
@JonathanBrouwer
Copy link
Contributor

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 3, 2026

📌 Commit fa8c970 has been approved by JonathanBrouwer

It is now in the queue for this repository.

@JonathanBrouwer
Copy link
Contributor

@bors r-
Found another one haha
#153334 (comment)

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 3, 2026

Commit fa8c970 has been unapproved.

This PR was contained in a rollup (#153334), which was also unapproved.

@mu001999
Copy link
Contributor Author

mu001999 commented Mar 3, 2026

@bors try jobs=dist-i586-gnu-i586-i686-musl

@rust-bors

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 3, 2026

☀️ Try build successful (CI)
Build commit: 27e632c (27e632c9e69a46630ab1b3902ec7c18d88cc44d4, parent: 1b7d722f429f09c87b08b757d89c689c6cf7f6e7)

@mu001999
Copy link
Contributor Author

mu001999 commented Mar 3, 2026

@rustbot ready

@JonathanBrouwer
Copy link
Contributor

@bors r+
Let's try again!

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 3, 2026

📌 Commit a03c9ab has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 3, 2026

⌛ Testing commit a03c9ab with merge 1b25151...

Workflow: https://github.com/rust-lang/rust/actions/runs/22636390058

@JonathanBrouwer
Copy link
Contributor

@JonathanBrouwer
Copy link
Contributor

@bors cancel

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 3, 2026

Auto build cancelled. Cancelled workflows:

The next pull request likely to be tested is #153355.

@JonathanBrouwer
Copy link
Contributor

Got quite far this time tho! We're probably almost there

@JonathanBrouwer
Copy link
Contributor

@bors r-
Did bors not hear me?

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 3, 2026

Commit a03c9ab has been unapproved.

This PR was contained in a rollup (#153349), which was also unapproved.

@mu001999
Copy link
Contributor Author

mu001999 commented Mar 4, 2026

@bors try jobs=x86_64-mingw-2

@rust-bors

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 4, 2026

☀️ Try build successful (CI)
Build commit: 6a6f346 (6a6f346c3d35524f8d8eabbc9b4cdcf965897841, parent: d9563937fa3b030c5845811113505070109414d2)

@mu001999
Copy link
Contributor Author

mu001999 commented Mar 4, 2026

@rustbot ready

@JonathanBrouwer
Copy link
Contributor

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 4, 2026

📌 Commit 0436634 has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 4, 2026

⌛ Testing commit 0436634 with merge 0d4eda9...

Workflow: https://github.com/rust-lang/rust/actions/runs/22657329747

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rustc could warn if a feature is unused Re-enable detection of unused library #![feature] directives