Skip to content

Do not modify resolver outputs during lowering#155460

Open
cjgillot wants to merge 4 commits intorust-lang:mainfrom
cjgillot:unmut-resolver-ast
Open

Do not modify resolver outputs during lowering#155460
cjgillot wants to merge 4 commits intorust-lang:mainfrom
cjgillot:unmut-resolver-ast

Conversation

@cjgillot
Copy link
Copy Markdown
Contributor

Split from #142830

I believe this achieves the same thing as #153656 but in a much simpler way.

This PR forces AST->HIR lowering to stop mutating resolver outputs. Instead, it manages a few override maps that only live during lowering and are dropped afterwards.

r? @petrochenkov
cc @aerooneqq

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 17, 2026

Some changes occurred in compiler/rustc_ast_lowering/src/format.rs

cc @m-ou-se

@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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 17, 2026
@cjgillot
Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Apr 17, 2026
Do not modify resolver outputs during lowering
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 17, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 17, 2026

☀️ Try build successful (CI)
Build commit: fd1275a (fd1275a2d0718b26a05018665073cb854870b511, parent: f29256dd1420dc681bf4956e3012ffe9eccdc7e7)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (fd1275a): comparison URL.

Overall result: ❌✅ regressions and improvements - 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
@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
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.0%] 4
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 2.8%, secondary 3.2%)

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

mean range count
Regressions ❌
(primary)
2.8% [0.9%, 7.3%] 123
Regressions ❌
(secondary)
3.2% [0.9%, 8.0%] 48
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.8% [0.9%, 7.3%] 123

Cycles

Results (secondary -3.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.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.1% [-8.0%, -2.3%] 4
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 490.91s -> 488.306s (-0.53%)
Artifact size: 394.18 MiB -> 395.94 MiB (0.45%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 18, 2026
Comment thread compiler/rustc_middle/src/queries.rs Outdated
Comment thread compiler/rustc_middle/src/hir/mod.rs Outdated
Comment thread compiler/rustc_ast_lowering/src/lib.rs Outdated
}

let def_id = self.get_partial_res(expr.id)?.full_res()?.opt_def_id()?;
let def_id = self.partial_res_map.get(&expr.id)?.full_res()?.opt_def_id()?;
Copy link
Copy Markdown
Contributor

@petrochenkov petrochenkov Apr 20, 2026

Choose a reason for hiding this comment

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

This is a bit suspicious, why are we using partial_res_map directly instead of get_partial_res here?

View changes since the review

@petrochenkov petrochenkov 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 Apr 20, 2026
@cjgillot cjgillot force-pushed the unmut-resolver-ast branch from 1e6ae8e to a9cee38 Compare April 21, 2026 23:48
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 21, 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.

@cjgillot
Copy link
Copy Markdown
Contributor Author

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

rust-bors Bot commented Apr 21, 2026

⌛ Trying commit a9cee38 with merge 1c6d6e2

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

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

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 21, 2026
rust-bors Bot pushed a commit that referenced this pull request Apr 21, 2026
Do not modify resolver outputs during lowering
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-perf Status: Waiting on a perf run to be completed. 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