Skip to content

rustc-lint: avoid allocation and Ident reconstruction in find_duplicated_parameters - #166492

Open
train-dev-admin wants to merge 1 commit into
rust-lang:mainfrom
train-dev-admin:issue-166410-fix
Open

train-dev-admin wants to merge 1 commit into
rust-lang:mainfrom
train-dev-admin:issue-166410-fix

Conversation

@train-dev-admin

@train-dev-admin train-dev-admin commented Nov 24, 2026 •

Copy link
Copy Markdown

Fixes #166410
Slowdown came from the lint in #165366 and showed up on externs and libc

Skip checking functions with fewer than 2 parameters.
Use a stack-allocated SmallVec instead of FxHashMap for small parameters lists.

Compare (Symbol, SyntaxContext) directly to avoid calling Ident::normalize_to_macro_rules()

The warnings are unchanged, I ran tests/ui/lint/duplicate-parameter-names.rs,
but looks like we need to do perf again: time regression on externs and libc should be less.

…ted_parameters

Skip checking functions with fewer than 2 parameters.

Use a stack-allocated SmallVec instead of FxHashMap for small parameters lists

Compare (Symbol, SyntaxContext) directly to avoid calling Ident::normalize_to_macro_rules()
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 24, 2026
@rustbot

rustbot commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @wesleywiser (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 79 candidates
  • Random selection from 21 candidates

@JonathanBrouwer

Copy link
Copy Markdown
Member

r? me

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 24, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 24, 2026
rustc-lint: avoid allocation and Ident reconstruction in find_duplicated_parameters
}

// 16 bytes per entry (Symbol: 4B, SyntaxContext: 4B, Span: 8B) -> 128B on stack
let mut seen: SmallVec<[(Symbol, SyntaxContext, Span); 8]> = SmallVec::new();

@JonathanBrouwer JonathanBrouwer Nov 24, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This does have O(n^2) behaviour, but if you're running into that there are probably bigger problems

View changes since the review

@rust-bors

rust-bors Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: dccab3d (dccab3db509e9610ab796ec9fdd9bb547a2c70a2)
Base parent: 058c701 (058c701055c4b6f60f622d616afc0349911c38c3)

@rust-timer

Copy link
Copy Markdown
Collaborator

Queued dccab3d with parent 058c701, future comparison URL.
There are currently 8 preceding artifacts in the queue.
It will probably take at least ~8.2 hours until the benchmark run finishes.

This branch has not been deployed

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

Labels

S-waiting-on-perf Status: Waiting on a perf run to be completed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Addressing perf regression from DUPLICATE_PARAMETER_NAMES lint

5 participants