Skip to content

Use per-parent disambiguators everywhere#155547

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
aerooneqq:better-disambiguators
Apr 22, 2026
Merged

Use per-parent disambiguators everywhere#155547
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
aerooneqq:better-disambiguators

Conversation

@aerooneqq
Copy link
Copy Markdown
Contributor

@aerooneqq aerooneqq commented Apr 20, 2026

View all comments

This PR addressing the following concerns about per-parent disambiguators (#153955):

  • DisambiguatorState is removed, PerParentDisambiguatorState is now used everywhere,
  • Steals were removed from every per-parent disambiguator in resolver,
  • It adds parent field in PerParentDisambiguatorState in #[cfg(debug_assertions)] for asserting that per-parent disambiguator corresponds to the same LocalDefId which is passed into create_def,
  • Removes Disambiguator trait replacing it with Disambiguator enum, with this change we no longer expose next method (as trait should be public otherwise the warning will be emitted). It may affect perf in a negative way though.

Those changes should not fix perf issues that were reported, perf run that was attempted before showed much better results. Performance can be probably fixed by removing per-parent disambiguators replacing them with a single one as it was before, then it will be passed to AST -> HIR lowering and modified. For delayed owners we can store followup disambiguators as it was in the beginning of the #153955 per-parent disambiguators. This solution should save achievements from #153955 (removed DefPathData variants).
However, I would prefer to keep per-parent disambiguators as it seems a better architectural solution for me.

r? @petrochenkov
cc @oli-obk

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 20, 2026

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Apr 20, 2026
@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented Apr 20, 2026

per parent logic is definitely the right thing, and we should take small hits now to clean all that up.

Comment thread compiler/rustc_const_eval/src/interpret/intern.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs Outdated
Comment thread compiler/rustc_mir_transform/src/coroutine/by_move_body.rs Outdated
Comment thread compiler/rustc_ty_utils/src/assoc.rs Outdated
Comment thread compiler/rustc_resolve/src/lib.rs Outdated
@oli-obk oli-obk self-assigned this Apr 20, 2026
@rust-log-analyzer

This comment has been minimized.

@aerooneqq
Copy link
Copy Markdown
Contributor Author

@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 Apr 20, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 20, 2026

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

@rust-bors

This comment has been minimized.

@aerooneqq aerooneqq force-pushed the better-disambiguators branch from 070d246 to 910edf3 Compare April 21, 2026 10:46
@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.

Comment thread compiler/rustc_ast_lowering/src/item.rs Outdated
Copy link
Copy Markdown
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

just a nit, then lgtm

View changes since this review

Comment thread compiler/rustc_ast_lowering/src/item.rs Outdated
Comment thread compiler/rustc_hir/src/definitions.rs Outdated
@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_ast_lowering/src/lib.rs
@aerooneqq
Copy link
Copy Markdown
Contributor Author

@rustbot ready

Lets try run perf, a lot of things have changed.

@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 Apr 21, 2026
@rust-log-analyzer

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 21, 2026

📌 Commit 3ed10c2 has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 21, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 21, 2026
@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented Apr 21, 2026

@bors try @rust-timer queue

The changes seemed innocent enough, but yea, there have been surprises in this are before

@rust-timer

This comment has been minimized.

@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 Apr 21, 2026
rust-bors Bot pushed a commit that referenced this pull request Apr 21, 2026
Comment thread compiler/rustc_hir/src/definitions.rs
Comment thread compiler/rustc_hir/src/definitions.rs
Comment thread compiler/rustc_resolve/src/lib.rs Outdated
@petrochenkov
Copy link
Copy Markdown
Contributor

(Please also squash commits before merging.)

@petrochenkov petrochenkov removed their assignment Apr 21, 2026
@petrochenkov
Copy link
Copy Markdown
Contributor

This looks sort of messy now compared to what we have on master, I guess it's the cost of using PerParentDisambiguatorState everywhere and avoiding Steal.

@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented Apr 21, 2026

This looks sort of messy now compared to what we have on master, I guess it's the cost of using PerParentDisambiguatorState everywhere and avoiding Steal.

I think it should get better once I do the cleanups mentioned earlier in this PR.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 21, 2026

☀️ Try build successful (CI)
Build commit: 07b9436 (07b94367b014d301ae457797f418cb5d79526b42, parent: 9ab01ae53c416f89fe256b79588a76dcbcdc9290)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (07b9436): comparison URL.

Overall result: no relevant changes - no action needed

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.

@bors rollup=never
@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.7%, 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.7% [1.7%, 1.7%] 1
Regressions ❌
(secondary)
1.7% [1.7%, 1.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.7% [1.7%, 1.7%] 1

Cycles

Results (primary 3.1%, secondary 3.9%)

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

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

Binary size

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

Bootstrap: 490.352s -> 489.481s (-0.18%)
Artifact size: 394.40 MiB -> 394.42 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 21, 2026
@aerooneqq aerooneqq force-pushed the better-disambiguators branch from b7070f3 to 2e6a082 Compare April 21, 2026 15:24
@aerooneqq
Copy link
Copy Markdown
Contributor Author

@rustbot ready

@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 Apr 21, 2026
@aerooneqq aerooneqq changed the title Better disambiguators Use per-parent disambiguators everywhere Apr 21, 2026
@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented Apr 21, 2026

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 21, 2026

📌 Commit 2e6a082 has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 21, 2026
rust-bors Bot pushed a commit that referenced this pull request Apr 21, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #155546 (Improve E0308 error message for `impl Trait` return mismatches)
 - #152834 (Fix incorrect `let` to `const` suggestion for pattern bindings)
 - #155425 (Remove duplicated `Flags` methods.)
 - #155547 (Use per-parent disambiguators everywhere)
 - #155590 (Remove AttributeLintKind variants - part 5)
@rust-bors rust-bors Bot merged commit aa33354 into rust-lang:main Apr 22, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 22, 2026
rust-timer added a commit that referenced this pull request Apr 22, 2026
Rollup merge of #155547 - aerooneqq:better-disambiguators, r=oli-obk

Use per-parent disambiguators everywhere

This PR addressing the following concerns about per-parent disambiguators (#153955):

- DisambiguatorState is removed, PerParentDisambiguatorState is now used everywhere,
- Steals were removed from every per-parent disambiguator in resolver,
- It adds `parent` field in `PerParentDisambiguatorState` in `#[cfg(debug_assertions)]` for asserting that per-parent disambiguator corresponds to the same `LocalDefId` which is passed into `create_def`,
- ~Removes `Disambiguator` trait replacing it with `Disambiguator` enum, with this change we no longer expose `next` method (as trait should be public otherwise the warning will be emitted). It may affect perf in a negative way though.~

~Those changes should not fix perf issues that were [reported](#153955 (comment)), perf run that was attempted [before](#153955 (comment)) showed much better results. Performance can be probably fixed by removing per-parent disambiguators replacing them with a single one as it was before, then it will be passed to AST -> HIR lowering and modified. For delayed owners we can store ~followup disambiguators as it was in the beginning of the #153955~ per-parent disambiguators. This solution should save achievements from #153955 (removed `DefPathData` variants).
However, I would prefer to keep per-parent disambiguators as it seems a better architectural solution for me.~

r? @petrochenkov
cc @oli-obk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants