Skip to content

-Znext-solver Eager normalization outside of solver #155767

Merged
rust-bors[bot] merged 6 commits intorust-lang:mainfrom
adwinwhite:eager-norm-outside
May 3, 2026
Merged

-Znext-solver Eager normalization outside of solver #155767
rust-bors[bot] merged 6 commits intorust-lang:mainfrom
adwinwhite:eager-norm-outside

Conversation

@adwinwhite
Copy link
Copy Markdown
Contributor

@adwinwhite adwinwhite commented Apr 25, 2026

View all comments

This PR adds a normalization routine for the next solver that behaves the same as the normalization in the old solver.
The new routine is used to normalize eagerly outside of the next solver.

This is part 2 of modifying the next solver to support eager normalization.

Those test changes are mostly wording changes, duplicating some errors or reducing some duplicates. But I could have overlooked something.
Notably it fixes the first, third and fourth examples in rust-lang/trait-system-refactor-initiative#191, but not the second variant.

It's probably easier to review commit by commit.

Fixes #151308
Fixes #101557
Fixes #119692
Fixes #136859

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Apr 25, 2026
@matthiaskrgr
Copy link
Copy Markdown
Member

does this fix #151308 ?

@rust-log-analyzer

This comment has been minimized.

@adwinwhite
Copy link
Copy Markdown
Contributor Author

adwinwhite commented Apr 25, 2026

does this fix #151308 ?

Yes, it probably fixes a bunch of issues. And unfix some issues fixed by the next solver? Unsure about that.
Seems tedious to re-triage those labelled fixed-by-the-next-solver 🤔

@adwinwhite
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 25, 2026
`-Znext-solver` Eager normalization outside of solver
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 25, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 25, 2026

☀️ Try build successful (CI)
Build commit: 59cc905 (59cc90511d0283377de9ba5a516f11853e3c95a9, parent: 7e0430fafc66bd0fdfaff94e65148a1f207438cd)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (59cc905): 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)
2.2% [0.5%, 7.3%] 12
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 2
Improvements ✅
(secondary)
-2.4% [-5.0%, -0.2%] 3
All ❌✅ (primary) -0.3% [-0.3%, -0.3%] 2

Max RSS (memory usage)

Results (primary -2.5%, secondary -1.6%)

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
Improvements ✅
(primary)
-2.5% [-2.8%, -2.2%] 2
Improvements ✅
(secondary)
-1.6% [-2.2%, -1.1%] 2
All ❌✅ (primary) -2.5% [-2.8%, -2.2%] 2

Cycles

Results (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)
- - 0
Regressions ❌
(secondary)
3.9% [3.4%, 4.3%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 491.487s -> 483.564s (-1.61%)
Artifact size: 394.23 MiB -> 393.40 MiB (-0.21%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 25, 2026
Comment thread compiler/rustc_trait_selection/src/solve/normalize.rs Outdated
@adwinwhite
Copy link
Copy Markdown
Contributor Author

adwinwhite commented Apr 27, 2026

Better get some quick feedback before I go too far in wrong direction/details.

r? lcnr

pub struct Normalized<'tcx, T> {
pub value: T,
pub obligations: PredicateObligations<'tcx>,
pub has_ambig_hr_alias: bool,
Copy link
Copy Markdown
Contributor Author

@adwinwhite adwinwhite Apr 27, 2026

Choose a reason for hiding this comment

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

Currently unused. Unsure how to propagate it out to be accessed. Many normalization routines have T -> T signature.

View changes since the review

Comment thread compiler/rustc_hir_analysis/src/check/check.rs Outdated
Comment thread compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs Outdated
Comment thread compiler/rustc_trait_selection/src/traits/coherence.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/check/check.rs Outdated
Comment thread compiler/rustc_trait_selection/src/solve/normalize.rs Outdated
Copy link
Copy Markdown
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

  • has_ambig_hr_alias does not feel useful to me, I think we can avoid it entirely
  • given that we allow for infer vars in our type, we need to handle both ty.has_aliases and ty.has_infer and need to shallow resolve at the start of fold_ty and fold_const

I would very much like to merge deeply_normalize and this one. The fact that deeply_normalize eagerly errors feels like an impl detail to me.

Instead of doing evaluate_all_error_on_ambiguity_stall_coroutine_predicates at every normalize_alias_term, we should be able to just use try_evaluate_obligations there, and then have the normalize_error_on_ambiguity which takes all the currently pending goals. puts em into another fulfillment context, and does the current evaluate_all_error_on_ambiguity_stall_coroutine_predicates for all normalization goals at once.

View changes since this review

@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_hir_analysis/src/autoderef.rs Outdated
Comment thread compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs Outdated
@adwinwhite adwinwhite force-pushed the eager-norm-outside branch from 2488143 to 03cabe7 Compare May 2, 2026 13:35
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 2, 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.

@adwinwhite
Copy link
Copy Markdown
Contributor Author

@bors r=lcnr rollup=never

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 2, 2026

📌 Commit 03cabe7 has been approved by lcnr

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 2, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 3, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 3, 2026

☀️ Test successful - CI
Approved by: lcnr
Duration: 3h 12m 30s
Pushing a3e96d8 to main...

@rust-bors rust-bors Bot merged commit a3e96d8 into rust-lang:main May 3, 2026
12 checks passed
@rustbot rustbot added this to the 1.97.0 milestone May 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 20de910 (parent) -> a3e96d8 (this PR)

Test differences

Show 96 test diffs

Stage 1

  • [crashes] tests/crashes/101557.rs: pass -> [missing] (J1)
  • [crashes] tests/crashes/119692.rs: pass -> [missing] (J1)
  • [crashes] tests/crashes/136859.rs: pass -> [missing] (J1)
  • [crashes] tests/crashes/155761-1.rs: [missing] -> pass (J1)
  • [ui] tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.rs: [missing] -> pass (J1)
  • [ui] tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs#current: pass -> [missing] (J1)
  • [ui] tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs#next: pass -> [missing] (J1)
  • [ui] tests/ui/traits/next-solver/self-referential-closure-sig-1.rs#next: [missing] -> pass (J1)
  • [ui] tests/ui/traits/next-solver/self-referential-closure-sig-1.rs#old: [missing] -> pass (J1)
  • [ui] tests/ui/traits/next-solver/self-referential-closure-sig-3.rs#next: [missing] -> pass (J1)
  • [ui] tests/ui/traits/next-solver/self-referential-closure-sig-3.rs#old: [missing] -> pass (J1)
  • [ui] tests/ui/traits/next-solver/self-referential-closure-sig-4.rs#next: [missing] -> pass (J1)
  • [ui] tests/ui/traits/next-solver/self-referential-closure-sig-4.rs#old: [missing] -> pass (J1)

Stage 2

  • [crashes] tests/crashes/101557.rs: pass -> [missing] (J0)
  • [crashes] tests/crashes/119692.rs: pass -> [missing] (J0)
  • [crashes] tests/crashes/136859.rs: pass -> [missing] (J0)
  • [crashes] tests/crashes/155761-1.rs: [missing] -> pass (J0)
  • [ui] tests/ui/traits/next-solver/normalize/dont-ice-on-normalization-failure.rs: [missing] -> pass (J2)
  • [ui] tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs#current: pass -> [missing] (J2)
  • [ui] tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs#next: pass -> [missing] (J2)
  • [ui] tests/ui/traits/next-solver/self-referential-closure-sig-1.rs#next: [missing] -> pass (J2)
  • [ui] tests/ui/traits/next-solver/self-referential-closure-sig-1.rs#old: [missing] -> pass (J2)
  • [ui] tests/ui/traits/next-solver/self-referential-closure-sig-3.rs#next: [missing] -> pass (J2)
  • [ui] tests/ui/traits/next-solver/self-referential-closure-sig-3.rs#old: [missing] -> pass (J2)
  • [ui] tests/ui/traits/next-solver/self-referential-closure-sig-4.rs#next: [missing] -> pass (J2)
  • [ui] tests/ui/traits/next-solver/self-referential-closure-sig-4.rs#old: [missing] -> pass (J2)

Additionally, 70 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard a3e96d8cb8a420022828d0a595277ad3671928a7 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-rust-for-linux: 40m 15s -> 51m 37s (+28.3%)
  2. x86_64-gnu-debug: 2h 7m -> 1h 31m (-27.9%)
  3. test-various: 1h 38m -> 2h 4m (+27.3%)
  4. i686-gnu-nopt-1: 2h 23m -> 1h 46m (-26.2%)
  5. armhf-gnu: 1h 11m -> 1h 29m (+25.3%)
  6. dist-i686-msvc: 2h 23m -> 1h 50m (-23.1%)
  7. dist-i686-linux: 1h 47m -> 1h 26m (-20.2%)
  8. aarch64-apple: 3h 6m -> 2h 28m (-20.1%)
  9. x86_64-msvc-ext2: 1h 47m -> 2h 4m (+15.6%)
  10. x86_64-msvc-1: 2h 30m -> 2h 46m (+10.6%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

A job failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
  COMMIT_MESSAGE: cargo update 
##[endgroup]
Downloading single artifact
Preparing to download the following artifacts:
- Cargo-lock (ID: 6766890992, Size: 50828, Expected Digest: sha256:1560167d1a16d67a2f1416b177526966a86eced41c3b9ee920d34b06122aae13)
Redirecting to blob download url: https://productionresultssa1.blob.core.windows.net/actions-results/20adfd56-3407-4d52-8a39-1ee962432e4a/workflow-job-run-05aa044e-4ebb-5f79-ac30-3264d268ef08/artifacts/858175980ba8726bab9f963fd06060d5199d874bbd735e523e2d990d354f8c0b.zip
Starting download of artifact to: /home/runner/work/rust/rust
(node:2283) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
SHA256 digest of downloaded artifact is 1560167d1a16d67a2f1416b177526966a86eced41c3b9ee920d34b06122aae13
Artifact download completed successfully.
Total of 1 artifact(s) downloaded
Download artifact has finished successfully
---
  COMMIT_MESSAGE: cargo update 
##[endgroup]
Downloading single artifact
Preparing to download the following artifacts:
- cargo-updates (ID: 6766891073, Size: 2920, Expected Digest: sha256:79e37795c23ea623d26e2efdd8aaa26674070d10fa45319c637d381547655d5f)
Redirecting to blob download url: https://productionresultssa1.blob.core.windows.net/actions-results/20adfd56-3407-4d52-8a39-1ee962432e4a/workflow-job-run-05aa044e-4ebb-5f79-ac30-3264d268ef08/artifacts/ce9034d4568b3430f906da1368ae1cf3e14ef1542859eb2e8d635c0876371f53.zip
Starting download of artifact to: /home/runner/work/rust/rust
(node:2294) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
SHA256 digest of downloaded artifact is 79e37795c23ea623d26e2efdd8aaa26674070d10fa45319c637d381547655d5f
Artifact download completed successfully.
Total of 1 artifact(s) downloaded
Download artifact has finished successfully
##[group]Run echo "${COMMIT_MESSAGE}" > commit.txt
echo "${COMMIT_MESSAGE}" > commit.txt
cat cargo_update.log >> commit.txt

echo "${PR_MESSAGE}" > body.md
echo '```txt' >> body.md
cat cargo_update.log >> body.md
echo '```' >> body.md
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
---
dep-bumps
following is the output from `cargo update`:
  COMMIT_MESSAGE: cargo update 
##[endgroup]
##[group]Run git config user.name github-actions
git config user.name github-actions
git config user.email [email protected]
git switch --force-create cargo_update
git add ./Cargo.lock ./library/Cargo.lock ./src/tools/rustbook/Cargo.lock
git commit --no-verify --file=commit.txt
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
---
dep-bumps
following is the output from `cargo update`:
  COMMIT_MESSAGE: cargo update 
##[endgroup]
remote: error: GH013: Repository rule violations found for refs/heads/cargo_update.        
remote: Review all repository rules at https://github.com/rust-lang/rust/rules?ref=refs%2Fheads%2Fcargo_update        
remote: 
remote: - Cannot update this protected ref.        
remote: 
remote: - Changes must be made through a pull request.        
remote: 
remote: - Cannot force-push to this branch        
remote: 
To https://github.com/rust-lang/rust
 ! [remote rejected]   cargo_update -> cargo_update (push declined due to repository rule violations)
error: failed to push some refs to 'https://github.com/rust-lang/rust'
##[error]Process completed with exit code 1.
Post job cleanup.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (a3e96d8): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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%] 2
Regressions ❌
(secondary)
4.6% [0.1%, 11.4%] 8
Improvements ✅
(primary)
-0.4% [-0.5%, -0.3%] 7
Improvements ✅
(secondary)
-1.6% [-6.4%, -0.0%] 18
All ❌✅ (primary) -0.2% [-0.5%, 0.3%] 9

Max RSS (memory usage)

Results (primary -2.7%, secondary -0.1%)

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)
1.9% [0.9%, 3.0%] 9
Improvements ✅
(primary)
-2.7% [-2.7%, -2.7%] 1
Improvements ✅
(secondary)
-2.8% [-6.1%, -0.5%] 7
All ❌✅ (primary) -2.7% [-2.7%, -2.7%] 1

Cycles

Results (secondary 1.1%)

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)
5.3% [0.6%, 11.5%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.6% [-8.1%, -0.6%] 8
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 482.455s -> 498.188s (3.26%)
Artifact size: 391.12 MiB -> 394.46 MiB (0.85%)

@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented May 4, 2026

non-next solver is mostly noise, the typenum regression is acceptable

@panstromek
Copy link
Copy Markdown
Contributor

perf triage:

Marking as triaged based on the comment above. Note that new solver is not enabled by default. Diesel regression looks maybe real to me, but it's very tiny so either way it seems like an acceptable trade-off for a step forward in this work.

@rustbot label: +perf-regression-triaged

jhpratt added a commit to jhpratt/rust that referenced this pull request May 5, 2026
move generalization test

The forth test of rust-lang/trait-system-refactor-initiative#191 (comment) isn't actually related to closure signature inference.

closes rust-lang/trait-system-refactor-initiative#191, which has already been fixed by rust-lang#155767

r? types
jhpratt added a commit to jhpratt/rust that referenced this pull request May 5, 2026
move generalization test

The forth test of rust-lang/trait-system-refactor-initiative#191 (comment) isn't actually related to closure signature inference.

closes rust-lang/trait-system-refactor-initiative#191, which has already been fixed by rust-lang#155767

r? types
jhpratt added a commit to jhpratt/rust that referenced this pull request May 6, 2026
move generalization test

The forth test of rust-lang/trait-system-refactor-initiative#191 (comment) isn't actually related to closure signature inference.

closes rust-lang/trait-system-refactor-initiative#191, which has already been fixed by rust-lang#155767

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

Labels

merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

8 participants