Skip to content

Lower to hir::Params for required trait functions - #166147

Open
JonathanBrouwer wants to merge 6 commits into
rust-lang:mainfrom
JonathanBrouwer:param6
Open

JonathanBrouwer wants to merge 6 commits into
rust-lang:mainfrom
JonathanBrouwer:param6

Conversation

@JonathanBrouwer

@JonathanBrouwer JonathanBrouwer commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

View all comments

The same as #166142, but for required trait functions.
Also includes a bunch of cleanup.

I recommend reviewing commit by commit, every commit passes tests.
Earlier commits leave TODOs that are fixed by later commits

Part of #164357
r? Kivooeo

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 18, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 18, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 18, 2026
Lower to `hir::Params` for required trait functions
@rust-bors

This comment was marked as outdated.

@rust-timer

This comment has been minimized.

@JonathanBrouwer JonathanBrouwer changed the title Lower to hir::Params for required trait functions Lower to hir::Params for required trait functions Nov 18, 2026
@rust-timer

This comment was marked as outdated.

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 18, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 23, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 23, 2026
Lower to `hir::Param`s for required trait functions
@JonathanBrouwer
JonathanBrouwer marked this pull request as ready for review November 23, 2026 08:22
@rustbot

rustbot commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Changes to the size of AST and/or HIR nodes.

cc @nnethercote

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

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

rust-bors Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 0f49c8c (0f49c8cbcbce91be3ca4a9bf80ee7dc6087506a6)
Base parent: 5debe6a (5debe6a1244452beced762385f88a51857a915fc)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (0f49c8c): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

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

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary 1.4%, secondary 1.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.4% [1.4%, 1.4%] 1
Regressions ❌
(secondary)
2.9% [1.0%, 6.6%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.1% [-2.4%, -0.4%] 3
All ❌✅ (primary) 1.4% [1.4%, 1.4%] 1

Cycles

Results (secondary -0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.7% [0.7%, 0.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.7% [-0.7%, -0.7%] 1
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 460.778s -> 458.292s (-0.54%)
Artifact size: 405.75 MiB -> 405.85 MiB (0.02%)

@rustbot rustbot removed perf-regression Performance regression. S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 23, 2026

@Kivooeo Kivooeo left a comment •

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.

One 🧊 and one nit, otherwise looks good

I have found other small problem with a comment, but since it was existed before I guess I would just open an issue where I explain it and assign you if you don't mind of such workflow

View changes since this review

TraitItemKind::Fn(ref sig, TraitFn::Required(params)) => {
try_visit!(visitor.visit_fn_decl(sig.decl));
for ident in param_idents.iter().copied() {
visit_opt!(visitor, visit_ident, ident);

@Kivooeo Kivooeo 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 unwrap in clippy becomes reachable

https://github.com/rust-lang/rust-clippy/blob/c132618b27b340db96c591bc4efcb169a1c99b25/clippy_lints/src/shadow.rs#L142

Small reproducer:

#![warn(clippy::shadow_unrelated)]

pub trait Required {
    fn method(argument: u8);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed. Welp, let's hope we caught em all now.

This bug was also already introduced for foreign functions by #166142.
I've added that as a regression test for that as well.

TraitFn::Required(sig) => (None, Some(sig)),
TraitFn::Provided(id) => (Some(id), None),
let (body, params) = match *body {
TraitFn::Required(sig) => (None, sig),

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.

Suggested change
TraitFn::Required(sig) => (None, sig),
TraitFn::Required(param) => (None, param),

small naming nit since TraitFn::Required now holds &'hir [Param<'hir>]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll rename it to params (since it's multiple)

@rustbot

rustbot commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

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.

@JonathanBrouwer

JonathanBrouwer commented Nov 24, 2026 •

Copy link
Copy Markdown
Member Author

Processed the feedback
@rustbot ready

I have found other small problem with a comment, but since it was existed before I guess I would just open an issue where I explain it and assign you if you don't mind of such workflow

This works well for me.
If it's just a comment thing and I can fix it in one minute, just including it in this PR as review is better though, not worth the effort to make an entire separate PR for it :)

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-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants