Skip to content

Conversation

@adwinwhite
Copy link
Contributor

And also split assembly_and_merge_candidates for HostEffect and NormalizesTo goals.

r? @lcnr

also split the `assembly_and_merge_candidates` for `HostEffect` and `NormalizesTo`
@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 Dec 2, 2025
Copy link
Contributor Author

@adwinwhite adwinwhite Dec 2, 2025

Choose a reason for hiding this comment

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

Not sure whether candidate preference matters to effect goal.

Copy link
Contributor

Choose a reason for hiding this comment

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

it's whatever :> please add a FIXME(const_traits) to assemble_and_merge_candidates that this was copied from the old projection normalization behavior and might not be what we actually want here

//
// We currently intentionally do not guide inference this way.
// Since we skip proving the trait goal in normalizes-to goal now, the normalizes-to
// goal can successfully resolve the infer var via param env.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems unavoidable since we don't know whether the trait goal will succeed or not at this time.

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
error in revision `next`: ui test did not emit an error
note: by default, ui tests are expected not to compile.
hint: use check-pass, build-pass, or run-pass directive to change this behavior.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/coherence/indirect-impl-for-trait-obj-coherence.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "next" "--check-cfg" "cfg(test,FALSE,current,next)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/coherence/indirect-impl-for-trait-obj-coherence.next" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Znext-solver"
stdout: none
stderr: none

---- [ui] tests/ui/coherence/indirect-impl-for-trait-obj-coherence.rs#next stdout end ----
---- [ui] tests/ui/impl-trait/non-defining-uses/use-blanket-impl.rs#next stdout ----

error in revision `next`: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/impl-trait/non-defining-uses/use-blanket-impl.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "next" "--check-cfg" "cfg(test,FALSE,current,next)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/impl-trait/non-defining-uses/use-blanket-impl.next" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Znext-solver"
stdout: none
--- stderr -------------------------------
error[E0282]: type annotations needed
##[error]  --> /checkout/tests/ui/impl-trait/non-defining-uses/use-blanket-impl.rs:13:13
   |
---
---- [ui] tests/ui/traits/next-solver/dyn-incompatibility.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/traits/next-solver/dyn-incompatibility/dyn-incompatibility.stderr`
diff of stderr:

15 LL | pub fn copy_any<T: std::marker::Copy>(t: &T) -> T {
16    |                  +++++++++++++++++++
17 
- error[E0308]: mismatched types
-   --> $DIR/dyn-incompatibility.rs:12:31
-    |
- LL |     copy::<dyn Setup<From=T>>(t)
-    |     ------------------------- ^ types differ
-    |     |
-    |     arguments to this function are incorrect
-    |
-    = note: expected reference `&<dyn Setup<From = T> as Setup>::From`
-               found reference `&T`
- note: function defined here
-   --> $DIR/dyn-incompatibility.rs:7:4
-    |
- LL | fn copy<U: Setup + ?Sized>(from: &U::From) -> U::From {
-    |    ^^^^                    --------------
- 
34 error[E0277]: the trait bound `T: Copy` is not satisfied in `dyn Setup<From = T>`
35   --> $DIR/dyn-incompatibility.rs:12:5
36    |

43 LL | pub fn copy_any<T: std::marker::Copy>(t: &T) -> T {
44    |                  +++++++++++++++++++
45 
- error: aborting due to 3 previous errors
+ error: aborting due to 2 previous errors
47 
---
To only update this specific test, also pass `--test-args traits/next-solver/dyn-incompatibility.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/traits/next-solver/dyn-incompatibility.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/traits/next-solver/dyn-incompatibility" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Znext-solver"
stdout: none
--- stderr -------------------------------
error[E0277]: the trait bound `T: Copy` is not satisfied in `dyn Setup<From = T>`
##[error]  --> /checkout/tests/ui/traits/next-solver/dyn-incompatibility.rs:12:12
   |
LL |     copy::<dyn Setup<From=T>>(t)
   |            ^^^^^^^^^^^^^^^^^ within `dyn Setup<From = T>`, the trait `Copy` is not implemented for `T`
   |
   = note: required because it appears within the type `dyn Setup<From = T>`
note: required by a bound in `copy`
  --> /checkout/tests/ui/traits/next-solver/dyn-incompatibility.rs:7:12
   |
LL | fn copy<U: Setup + ?Sized>(from: &U::From) -> U::From {
   |            ^^^^^ required by this bound in `copy`
help: consider restricting type parameter `T` with trait `Copy`
   |
LL | pub fn copy_any<T: std::marker::Copy>(t: &T) -> T {
   |                  +++++++++++++++++++

error[E0277]: the trait bound `T: Copy` is not satisfied in `dyn Setup<From = T>`
##[error]  --> /checkout/tests/ui/traits/next-solver/dyn-incompatibility.rs:12:5
   |
LL |     copy::<dyn Setup<From=T>>(t)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `dyn Setup<From = T>`, the trait `Copy` is not implemented for `T`
   |
   = note: required because it appears within the type `dyn Setup<From = T>`
help: consider restricting type parameter `T` with trait `Copy`
   |
LL | pub fn copy_any<T: std::marker::Copy>(t: &T) -> T {
   |                  +++++++++++++++++++

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.

@adwinwhite adwinwhite marked this pull request as draft December 2, 2025 08:44
@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 Dec 2, 2025
Copy link
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.

fun, this isn't quite the behavior of the old trait solver either :3

the old solver only skips trying to prove the trait goal of we've got a builtin trait object impls. I think this ended up not really being necessary after your previous work?

idk... this sucks xd

let's see if the change impacts perf in a major way. If so, we can still avoid assembling impls in some cases at least :3

View changes since this review

D: SolverDelegate<Interner = I>,
I: Interner,
{
pub(super) fn normalize_trait_associated_term(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub(super) fn normalize_trait_associated_term(
pub(super) fn normalize_projection_term(

that's what we use in AliasTermKind 🤔

// We currently intentionally do not guide inference this way.
// Since we skip proving the trait goal in normalizes-to goal now, the normalizes-to
// goal can successfully resolve the infer var via param env.
// This causes the stalled ambiguous trait goal to succeed as well.
Copy link
Contributor

Choose a reason for hiding this comment

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

this also doesn't compile with the old solver right now 🤔 why?

ah, because the old solver always uses assemble_candidates_from_impls and forces ambiguity unless assembly resulted in a builtin trait object candidate :<

that's wild xx

Comment on lines +461 to +463
// We don't care about overflow. If proving the trait goal overflowed, then
// it's enough to report an overflow error for that, we don't also have to
// overflow during normalization.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// We don't care about overflow. If proving the trait goal overflowed, then
// it's enough to report an overflow error for that, we don't also have to
// overflow during normalization.
// We don't care about overflow. If proving the trait goal overflowed, then
// it's enough to report an overflow error for that, we don't also have to
// overflow for the const bound.

or sth

Copy link
Contributor

Choose a reason for hiding this comment

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

it's whatever :> please add a FIXME(const_traits) to assemble_and_merge_candidates that this was copied from the old projection normalization behavior and might not be what we actually want here

Comment on lines +106 to +108
// If we're normalizing an GAT, we bail if using a where-bound would constrain
// its generic arguments.
// FIXME(generic_associated_types): Addresses aggressive inference in #92917.
Copy link
Contributor

Choose a reason for hiding this comment

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

flip these two statements. I want the comment to start with the FIXME. Right now it seems like the first line is separate from the content of the FIXME

&mut self,
goal: Goal<I, ty::NormalizesTo<I>>,
) -> QueryResult<I> {
let (mut candidates, _) =
Copy link
Contributor

Choose a reason for hiding this comment

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

comment: something something we already looked for param_env and alias-bound candidates so we don't have to assemble them again

@lcnr
Copy link
Contributor

lcnr commented Dec 2, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Dec 2, 2025
skip proving the trait goal if possible in `NormalizesTo` goal
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 2, 2025
@rust-bors

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Dec 2, 2025

☀️ Try build successful (CI)
Build commit: 405e127 (405e127a5ed88fdce13f91d651e2346944cc27f1, parent: 47cd7120d9b4e1b64eb27c87522a07888197fae8)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (405e127): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@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
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-12.9% [-40.3%, -0.3%] 9
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary 0.3%)

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.6% [2.6%, 2.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.9% [-1.0%, -0.9%] 2
All ❌✅ (primary) - - 0

Cycles

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

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 469.029s -> 471.041s (0.43%)
Artifact size: 386.77 MiB -> 386.75 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 2, 2025
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-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.

5 participants