Skip to content

Fix ordering for default impl check in the new solver - #161268

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
nnethercote:fix-160994
Aug 22, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
nnethercote:fix-160994

Conversation

@nnethercote

@nnethercote nnethercote commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

The second commit of #160605 moved the default impl check later, for better performance, which introduced a regression. This commit moves the check a little earlier, so it is after the args_may_unify call (thus retaining the perf benefit) but before the probe_trait_candidate (which has side-effects).

The check is now duplicated in three GoalKind::consider_impl_candidate methods, which is unfortunate, but it fits in with the existing duplicated code in those methods. And it means another copy of the check (in try_assemble_bounds_via_registered_opaques) can be removed.

Fixes #160994.

r? @lcnr

The second commit of rust-lang#160605 moved the `default impl` check later, for
better performance, which introduced a regression. This commit moves the
check a little earlier, so it is after the `args_may_unify` call (thus
retaining the perf benefit) but before the `probe_trait_candidate`
(which has side-effects).

The check is now duplicated in three `GoalKind::consider_impl_candidate`
methods, which is unfortunate, but it fits in with the existing
duplicated code in those methods. And it means another copy of the
check (in `try_assemble_bounds_via_registered_opaques`) can be removed.

Fixes rust-lang#160994.
@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Aug 18, 2026
@rustbot

rustbot commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@nnethercote

Copy link
Copy Markdown
Contributor Author

LLM disclosure: an LLM helped with analysis and review of this PR. I wrote all the code and text myself.

@nnethercote

Copy link
Copy Markdown
Contributor 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 Aug 18, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 18, 2026
Fix ordering for `default impl` check in the new solver
@rust-bors

rust-bors Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 71c4692 (71c4692a099ddb94f11b4c9e214701c81b4f8803)
Base parent: 8fa1c96 (8fa1c96cfd489e4c27654c144ae871ce2c4db6c6)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (71c4692): 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
Regressions ❌
(secondary)
0.8% [0.5%, 1.2%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 2.2%)

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

mean range count
Regressions ❌
(primary)
2.2% [2.1%, 2.2%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.2% [2.1%, 2.2%] 2

Cycles

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

Binary size

Results (primary -0.0%, 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
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 4
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 41
All ❌✅ (primary) -0.0% [-0.0%, -0.0%] 4

Bootstrap: 458.344s -> 457.305s (-0.23%)
Artifact size: 398.95 MiB -> 398.92 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 Aug 18, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

A slight perf regression, but needed for correctness, and it's only a small fraction of the improvement from #160605.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Aug 18, 2026

@lcnr lcnr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one other option: could we change the for_each_relevant_impl and for_each_blanket_impl queries to only return non-default impls and have a separate for_each_default_impl?

r=me on this change itself, even if I quite dislike default impls to negatively impact perf here

View changes since this review

@nnethercote

Copy link
Copy Markdown
Contributor Author

Let's merge this because it fixes a clear problem; the for_each_default_impl can be done as a follow-up.

@bors r=lcnr

@rust-bors

rust-bors Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 39b6dbe 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-review Status: Awaiting review from the assignee but also interested parties. labels Aug 19, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 19, 2026
Fix ordering for `default impl` check in the new solver

The second commit of #160605 moved the `default impl` check later, for better performance, which introduced a regression. This commit moves the check a little earlier, so it is after the `args_may_unify` call (thus retaining the perf benefit) but before the `probe_trait_candidate` (which has side-effects).

The check is now duplicated in three `GoalKind::consider_impl_candidate` methods, which is unfortunate, but it fits in with the existing duplicated code in those methods. And it means another copy of the check (in `try_assemble_bounds_via_registered_opaques`) can be removed.

Fixes #160994.

r? @lcnr
@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 19, 2026
@rust-bors

rust-bors Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

💔 Test for e17ef52 failed: CI. Failed job:

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job dist-x86_64-mingw failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] heck test:false 0.681
error: could not compile `heck` (lib)

Caused by:
  process didn't exit successfully: `D:\a\rust\rust\build\bootstrap\debug\rustc D:\a\rust\rust\build\bootstrap\debug\rustc --crate-name heck --edition=2021 C:\Users\runneradmin\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\heck-0.5.0\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off --check-cfg cfg(docsrs,test) --check-cfg "cfg(feature, values())" -C metadata=75d8e3eb8f5f9423 -C extra-filename=-a7bb6dca242938ef --out-dir D:\a\rust\rust\build\x86_64-pc-windows-gnu\bootstrap-tools\release\build\heck/a7bb6dca242938ef\out --cap-lints allow -Z binary-dep-depinfo` (exit code: 0xc00000fd, STATUS_STACK_OVERFLOW)
warning: build failed, waiting for other jobs to finish...
[RUSTC-TIMING] unicode_width test:false 0.437
[RUSTC-TIMING] serde_derive test:false 6.087
[RUSTC-TIMING] wasmparser test:false 22.059
Bootstrap failed while executing `dist bootstrap --include-default-paths`

@nnethercote

Copy link
Copy Markdown
Contributor Author

@bors retry

@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 Aug 20, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors p=6 scheduling

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

rust-bors Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: lcnr
Duration: 3h 3m 5s
Pushing 3009fdd to main...

@rust-bors
rust-bors Bot merged commit 3009fdd into rust-lang:main Aug 22, 2026
15 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Aug 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor
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 124c16e (parent) -> 3009fdd (this PR)

Test differences

Show 40 test diffs

Stage 1

  • [ui (polonius)] tests/ui/specialization/defaultimpl/out-of-order-2.rs#current: [missing] -> pass (J0)
  • [ui (polonius)] tests/ui/specialization/defaultimpl/out-of-order-2.rs#next: [missing] -> pass (J0)
  • [ui] tests/ui/specialization/defaultimpl/out-of-order-2.rs#current: [missing] -> pass (J2)
  • [ui] tests/ui/specialization/defaultimpl/out-of-order-2.rs#next: [missing] -> pass (J2)

Stage 2

  • [ui] tests/ui/specialization/defaultimpl/out-of-order-2.rs#current: [missing] -> pass (J1)
  • [ui] tests/ui/specialization/defaultimpl/out-of-order-2.rs#next: [missing] -> pass (J1)

Additionally, 34 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 3009fdd3756436133ed9ea6b165a655c28f6857a --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-gnu-llvm-21-2: 1h 9m -> 1h 42m (+47.6%)
  2. dist-x86_64-illumos: 1h 19m -> 1h 56m (+46.7%)
  3. x86_64-gnu-nopt: 1h 34m -> 2h 10m (+38.1%)
  4. x86_64-gnu: 1h 59m -> 2h 40m (+34.2%)
  5. dist-powerpc64-linux-musl: 1h 13m -> 1h 38m (+34.0%)
  6. dist-riscv64-linux-gnu: 1h 31m -> 1h 2m (-32.4%)
  7. x86_64-gnu-aux: 2h 1m -> 2h 38m (+30.9%)
  8. x86_64-gnu-llvm-21-1: 47m 10s -> 1h 1m (+30.0%)
  9. i686-gnu-1: 1h 46m -> 2h 17m (+29.8%)
  10. dist-aarch64-linux: 3h 35m -> 2h 31m (-29.7%)
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-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (3009fdd): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.8% [-1.3%, -0.5%] 6
All ❌✅ (primary) - - 0

Max RSS (memory usage)

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

Cycles

Results (primary -3.2%, secondary -5.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)
2.2% [2.1%, 2.3%] 2
Improvements ✅
(primary)
-3.2% [-3.2%, -3.2%] 1
Improvements ✅
(secondary)
-9.9% [-13.5%, -3.1%] 3
All ❌✅ (primary) -3.2% [-3.2%, -3.2%] 1

Binary size

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

Bootstrap: 467.816s -> 468.178s (0.08%)
Artifact size: 400.13 MiB -> 400.13 MiB (-0.00%)

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-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

Development

Successfully merging this pull request may close these issues.

[ICE]: missing item

6 participants