Skip to content

Prefer ModId in more places - #159787

Open
camsteffen wants to merge 4 commits into
rust-lang:mainfrom
camsteffen:fnctxt-modid
Open

Prefer ModId in more places#159787
camsteffen wants to merge 4 commits into
rust-lang:mainfrom
camsteffen:fnctxt-modid

Conversation

@camsteffen

@camsteffen camsteffen commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

View all comments

Simplifying code a bit and adding consistency. Generally prefer passing around ModId instead of a more specific ID when a ModId will do.

@rustbot

rustbot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

HIR ty lowering was modified

cc @fmease

@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 Jul 23, 2026
@rustbot

rustbot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

r? @mu001999

rustbot has assigned @mu001999.
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: compiler
  • compiler expanded to 74 candidates
  • Random selection from 20 candidates

@mu001999

Copy link
Copy Markdown
Member

@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 Jul 24, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 24, 2026
@rust-bors

rust-bors Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: d23ae58 (d23ae583eaadc5bb12614b8b6dc9e36776122523)
Base parent: 76c35a1 (76c35a14a45897a366c11657ecbbe9ec4153ad17)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (d23ae58): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.3%] 12
Regressions ❌
(secondary)
0.3% [0.1%, 0.5%] 18
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.2%, 0.3%] 12

Max RSS (memory usage)

Results (secondary -0.7%)

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)
2.7% [2.7%, 2.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.6%, -2.2%] 2
All ❌✅ (primary) - - 0

Cycles

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

Binary size

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

Bootstrap: 488.274s -> 486.771s (-0.31%)
Artifact size: 387.66 MiB -> 387.61 MiB (-0.01%)

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

mu001999 commented Jul 24, 2026

Copy link
Copy Markdown
Member

Seems this instead leads to a slight perf regression. Do you have any ideas?

@rustbot author

@rustbot rustbot 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 Jul 24, 2026
@rustbot

rustbot commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rust-bors

This comment has been minimized.

Use ModId more for visibility checks from TypeckRootCtxt. This just
simplifies things a bit and adds consistency.
We generally expect Visibility to have ModId or LocalModId, so it seems
good to restrict the impls as such. There is just one error path needing
adjustment to check that we actually have a ModId. It should be okay
since, if it is not a module, an error will be emitted elsewhere.
Especially in adjust_ident_and_get_scope and is_accessible_from.
@rustbot

rustbot commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

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 T-clippy Relevant to the Clippy team. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Aug 28, 2026
@rustbot

rustbot commented Aug 28, 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.

@camsteffen camsteffen changed the title Cache and use more ModId Prefer ModId in more places Aug 28, 2026
@camsteffen

Copy link
Copy Markdown
Contributor Author

This should be about perf neutral now. Adding a ModId to ItemCtxt was a loss so I took that out.

@mu001999

Copy link
Copy Markdown
Member

@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 Aug 28, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 28, 2026
@rust-bors

rust-bors Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 5eb45c3 (5eb45c324decbc218a78c4fc379dd769318e60d7)
Base parent: d0f2ef5 (d0f2ef5e53039bd86fdcaa6e71860c4948880e04)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (5eb45c3): 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 -2.3%, secondary 2.4%)

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)
7.1% [7.1%, 7.1%] 1
Improvements ✅
(primary)
-2.3% [-2.3%, -2.3%] 1
Improvements ✅
(secondary)
-2.3% [-2.3%, -2.3%] 1
All ❌✅ (primary) -2.3% [-2.3%, -2.3%] 1

Cycles

Results (primary -0.5%, secondary 10.6%)

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

mean range count
Regressions ❌
(primary)
3.2% [3.2%, 3.2%] 1
Regressions ❌
(secondary)
10.6% [3.0%, 18.3%] 4
Improvements ✅
(primary)
-2.4% [-2.6%, -2.2%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.5% [-2.6%, 3.2%] 3

Binary size

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

Bootstrap: 475.629s -> 474.896s (-0.15%)
Artifact size: 402.76 MiB -> 402.77 MiB (0.00%)

@rustbot rustbot removed perf-regression Performance regression. S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 28, 2026
let (module, _span) = tcx.hir_get_module(mod_id);

cx.with_lint_attrs(hir_id, |cx| {
cx.with_lint_attrs(HirId::make_owner(mod_id.to_local_def_id()), |cx| {

@mu001999 mu001999 Aug 28, 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.

Suggested change
cx.with_lint_attrs(HirId::make_owner(mod_id.to_local_def_id()), |cx| {
cx.with_lint_attrs(mod_id.into(), |cx| {

View changes since the review

@mu001999

Copy link
Copy Markdown
Member

r=me after nits

@rustbot author

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

Labels

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-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants