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
@mu001999
Copy link
Contributor Author

mu001999 commented Mar 1, 2026

@bors try jobs=test-various,x86_64-gnu-aux,x86_64-gnu-llvm-21-3,x86_64-msvc-1,aarch64-apple,x86_64-mingw-1

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 1, 2026
Lint unused features


try-job: test-various
try-job: x86_64-gnu-aux
try-job: x86_64-gnu-llvm-21-3
try-job: x86_64-msvc-1
try-job: aarch64-apple
try-job: x86_64-mingw-1
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the lint/unused_features branch from 1b42332 to 800231f Compare March 1, 2026 12:59
@mu001999
Copy link
Contributor Author

mu001999 commented Mar 1, 2026

@bors try jobs=test-various,x86_64-gnu-aux,x86_64-gnu-llvm-21-3,x86_64-msvc-1,aarch64-apple,x86_64-mingw-1

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 1, 2026
Lint unused features


try-job: test-various
try-job: x86_64-gnu-aux
try-job: x86_64-gnu-llvm-21-3
try-job: x86_64-msvc-1
try-job: aarch64-apple
try-job: x86_64-mingw-1
@rust-log-analyzer

This comment has been minimized.

@mu001999 mu001999 force-pushed the lint/unused_features branch from 800231f to b93e577 Compare March 1, 2026 15:34
@mu001999
Copy link
Contributor Author

mu001999 commented Mar 1, 2026

@bors try jobs=test-various,x86_64-gnu-aux,x86_64-gnu-llvm-21-3,x86_64-msvc-1,aarch64-apple,x86_64-mingw-1

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 1, 2026
Lint unused features


try-job: test-various
try-job: x86_64-gnu-aux
try-job: x86_64-gnu-llvm-21-3
try-job: x86_64-msvc-1
try-job: aarch64-apple
try-job: x86_64-mingw-1
@rust-log-analyzer

This comment has been minimized.

@rust-bors rust-bors bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 1, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 1, 2026

💔 Test for 9978a5a failed: CI. Failed jobs:

@rust-bors

This comment has been minimized.

@mu001999 mu001999 force-pushed the lint/unused_features branch from b93e577 to 9ee8403 Compare March 2, 2026 01:38
@rustbot
Copy link
Collaborator

rustbot commented Mar 2, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@mu001999
Copy link
Contributor Author

mu001999 commented Mar 2, 2026

@bors try jobs=test-various,x86_64-gnu-aux,x86_64-gnu-llvm-21-3,x86_64-msvc-1,aarch64-apple,x86_64-mingw-1

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 2, 2026

⌛ Trying commit 9ee8403 with merge 49fc547

To cancel the try build, run the command @bors try cancel.

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

rust-bors bot pushed a commit that referenced this pull request Mar 2, 2026
Lint unused features


try-job: test-various
try-job: x86_64-gnu-aux
try-job: x86_64-gnu-llvm-21-3
try-job: x86_64-msvc-1
try-job: aarch64-apple
try-job: x86_64-mingw-1
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
/dev/sda15      105M  6.2M   99M   6% /boot/efi
tmpfs           1.6G   12K  1.6G   1% /run/user/1001
================================================================================

Sufficient disk space available (94917504KB >= 52428800KB). Skipping cleanup.
##[group]Run echo "[CI_PR_NUMBER=$num]"
echo "[CI_PR_NUMBER=$num]"
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
---
tests/ui/drain_collect.fixed ... ok
tests/ui/drop_non_drop.rs ... ok
tests/ui/duplicate_underscore_argument.rs ... ok
tests/ui/duplicated_attributes.rs ... ok
tests/ui/duration_suboptimal_units_days_weeks.rs ... ok
tests/ui/duration_suboptimal_units.rs ... ok
tests/ui/duration_subsec.rs ... ok
tests/ui/double_parens.fixed ... ok
tests/ui/duration_suboptimal_units_days_weeks.fixed ... ok
tests/ui/duration_suboptimal_units.fixed ... ok
tests/ui/duration_subsec.fixed ... ok
tests/ui/elidable_lifetime_names.rs ... ok
tests/ui/empty_docs.rs ... ok
tests/ui/else_if_without_else.rs ... ok
tests/ui/eager_transmute.rs ... ok
---

[ERROR] An exception occured: Timed out after waiting 30000ms
== STACKTRACE ==
TimeoutError: Timed out after waiting 30000ms
    at /checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/node_modules/puppeteer-core/lib/cjs/puppeteer/common/util.js:246:19
    at /checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:3991:35
    at OperatorSubscriber2._this._next (/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:1055:13)
    at Subscriber2.next (/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:678:16)
    at AsyncAction2.<anonymous> (/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:4868:24)
    at AsyncAction2._execute (/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:1974:16)
    at AsyncAction2.execute (/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:1963:26)
    at AsyncScheduler2.flush (/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:2235:30)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)


<= doc-ui tests done: 141 succeeded, 1 failed, 0 filtered out

Error: ()

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-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. 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

10 participants