Skip to content

Clean-up used_underscore_*#17308

Open
Jarcho wants to merge 1 commit into
rust-lang:masterfrom
Jarcho:used_underscore
Open

Clean-up used_underscore_*#17308
Jarcho wants to merge 1 commit into
rust-lang:masterfrom
Jarcho:used_underscore

Conversation

@Jarcho

@Jarcho Jarcho commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

This primarily reorders things to do cheaper checks before more expensive checks, but there are also some smaller changes:

  • No macros are linted instead of only skipping external macros.
  • expect and allow on the item in used_underscore_items now work. used_undercore_bindings already did this.
  • is_used now more closely matches what unused_variables does. It takes very little for a variable to count as used.
  • consts/statics and all type relative paths are checked
  • Functions are linted if they're named, not just if they're called.

changelog: [used_underscore_bindings]: lint more cases where the binding is used
changelog: [used_underscore_items]: additionally check for allow end expect attributes on the item definition.

* Merge the code for both lints
* Don't lint in macros
* Allow `expect` and `allow` on the item's definition
* Better match `unused_variables`
* Re-order checks based on cost/effectivness.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 25, 2026
@rustbot

rustbot commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

r? @llogiq

rustbot has assigned @llogiq.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 8 candidates
  • 8 candidates expanded to 8 candidates
  • Random selection from dswij, llogiq, samueltardieu

@github-actions

Copy link
Copy Markdown

Lintcheck changes for 8082081

Lint Added Removed Changed
clippy::used_underscore_items 154 0 36

This comment will be updated if you push new changes

@llogiq

llogiq commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Can you add some tests to show the modified behavior re consts/statics etc.?

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants