From 3bc8827f723573b413ff0e5eabec215d979f8093 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 15:27:32 +0200 Subject: [PATCH 01/27] continue next-solver crashes triage --- tests/crashes/126680.rs | 25 --------------- tests/crashes/140850.rs | 7 ---- ...n-closure-capture-ice-119786-1.next.stderr | 0 .../in-closure-capture-ice-119786-1.rs | 0 .../in-closure-capture-ice-119786-2.rs | 0 .../in-closure-capture-ice-119786-3.rs | 0 ...atible-closure-captures-field-of-opaque.rs | 0 .../switch-int-terminator-126680.next.stderr | 21 ++++++++++++ .../switch-int-terminator-126680.rs | 32 +++++++++++++++++++ .../switch-int-terminator-140850.rs | 21 ++++++++++++ 10 files changed, 74 insertions(+), 32 deletions(-) delete mode 100644 tests/crashes/126680.rs delete mode 100644 tests/crashes/140850.rs rename tests/ui/impl-trait/{closures => normalize-hir-typeck}/in-closure-capture-ice-119786-1.next.stderr (100%) rename tests/ui/impl-trait/{closures => normalize-hir-typeck}/in-closure-capture-ice-119786-1.rs (100%) rename tests/ui/impl-trait/{closures => normalize-hir-typeck}/in-closure-capture-ice-119786-2.rs (100%) rename tests/ui/impl-trait/{closures => normalize-hir-typeck}/in-closure-capture-ice-119786-3.rs (100%) rename tests/ui/impl-trait/{closures => normalize-hir-typeck}/incompatible-closure-captures-field-of-opaque.rs (100%) create mode 100644 tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.next.stderr create mode 100644 tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.rs create mode 100644 tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-140850.rs diff --git a/tests/crashes/126680.rs b/tests/crashes/126680.rs deleted file mode 100644 index dcb6ccad6b422..0000000000000 --- a/tests/crashes/126680.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ known-bug: rust-lang/rust#126680 -//@ compile-flags: -Zvalidate-mir -#![feature(type_alias_impl_trait)] -type Bar = impl std::fmt::Display; - -use std::path::Path; - -struct A { - pub func: fn(check: Bar, b: Option<&Path>), -} - -#[define_opaque(Bar)] -fn foo() -> A { - A { - func: |check, b| { - if check { - () - } else if let Some(_) = b.and_then(|p| p.parent()) { - () - } - }, - } -} - -fn main() {} diff --git a/tests/crashes/140850.rs b/tests/crashes/140850.rs deleted file mode 100644 index fd26097deda00..0000000000000 --- a/tests/crashes/140850.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ known-bug: #140850 -//@ compile-flags: -Zvalidate-mir -fn A() -> impl { - while A() {} - loop {} -} -fn main() {} diff --git a/tests/ui/impl-trait/closures/in-closure-capture-ice-119786-1.next.stderr b/tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-119786-1.next.stderr similarity index 100% rename from tests/ui/impl-trait/closures/in-closure-capture-ice-119786-1.next.stderr rename to tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-119786-1.next.stderr diff --git a/tests/ui/impl-trait/closures/in-closure-capture-ice-119786-1.rs b/tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-119786-1.rs similarity index 100% rename from tests/ui/impl-trait/closures/in-closure-capture-ice-119786-1.rs rename to tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-119786-1.rs diff --git a/tests/ui/impl-trait/closures/in-closure-capture-ice-119786-2.rs b/tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-119786-2.rs similarity index 100% rename from tests/ui/impl-trait/closures/in-closure-capture-ice-119786-2.rs rename to tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-119786-2.rs diff --git a/tests/ui/impl-trait/closures/in-closure-capture-ice-119786-3.rs b/tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-119786-3.rs similarity index 100% rename from tests/ui/impl-trait/closures/in-closure-capture-ice-119786-3.rs rename to tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-119786-3.rs diff --git a/tests/ui/impl-trait/closures/incompatible-closure-captures-field-of-opaque.rs b/tests/ui/impl-trait/normalize-hir-typeck/incompatible-closure-captures-field-of-opaque.rs similarity index 100% rename from tests/ui/impl-trait/closures/incompatible-closure-captures-field-of-opaque.rs rename to tests/ui/impl-trait/normalize-hir-typeck/incompatible-closure-captures-field-of-opaque.rs diff --git a/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.next.stderr b/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.next.stderr new file mode 100644 index 0000000000000..47550ef9db818 --- /dev/null +++ b/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.next.stderr @@ -0,0 +1,21 @@ +error[E0391]: cycle detected when computing type of `Bar::{opaque#0}` + --> $DIR/switch-int-terminator-126680.rs:17:12 + | +LL | type Bar = impl Sized; + | ^^^^^^^^^^ + | + = note: ...which requires computing type of opaque `Bar::{opaque#0}`... +note: ...which requires borrow-checking `foo`... + --> $DIR/switch-int-terminator-126680.rs:26:1 + | +LL | fn foo() -> Struct { + | ^^^^^^^^^^^^^^^^^^ + = note: ...which requires promoting constants in MIR for `foo`... + = note: ...which requires normalizing `fn(Bar)`... + = note: ...which again requires computing type of `Bar::{opaque#0}`, completing the cycle + = note: cycle used when checking that `Bar::{opaque#0}` is well-formed + = note: for more information, see and + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.rs b/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.rs new file mode 100644 index 0000000000000..bb8e34ff35140 --- /dev/null +++ b/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.rs @@ -0,0 +1,32 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[next] known-bug: trait-system-refactor-initiative#303 +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #126680 +//@ compile-flags: -Zvalidate-mir +//@ edition:2021 + +// This ICE'd with the old solver as MIR build resulted in an opaque type +// as the argument to a `SwitchInt` terminator. Fixed by normalizing opaque +// types in their defining scope. Regression test for #126680. This should +// compile. + +#![feature(type_alias_impl_trait)] +type Bar = impl Sized; + +use std::path::Path; + +struct Struct { + pub func: fn(check: Bar), +} + +#[define_opaque(Bar)] +fn foo() -> Struct { + Struct { + func: |check| if check { () } else { () }, + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-140850.rs b/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-140850.rs new file mode 100644 index 0000000000000..513e4e382a4d9 --- /dev/null +++ b/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-140850.rs @@ -0,0 +1,21 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #140850 +//@[next] check-pass +//@ compile-flags: -Zvalidate-mir +//@ edition:2021 + +// This ICE'd with the old solver as MIR build resulted in an opaque type +// as the argument to a `SwitchInt` terminator. Fixed by normalizing opaque +// types in their defining scope. Regression test for #140850. + +fn foo() -> impl Sized { + if false { + while foo() {} + } + loop {} +} +fn main() {} From 5c5254e6e79f5498c82df2462a161f2951594905 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 15:45:48 +0200 Subject: [PATCH 02/27] cont tests/crashes migration --- tests/crashes/125553.rs | 15 ----------- .../in-closure-capture-ice-125553.rs | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+), 15 deletions(-) delete mode 100644 tests/crashes/125553.rs create mode 100644 tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-125553.rs diff --git a/tests/crashes/125553.rs b/tests/crashes/125553.rs deleted file mode 100644 index 142c06775bb87..0000000000000 --- a/tests/crashes/125553.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ known-bug: rust-lang/rust#125553 -//@ edition:2021 - -#[derive(Copy, Clone)] -struct Foo((u32, u32)); - -fn main() { - type T = impl Copy(Copy, Clone) - let foo: T = Foo((1u32, 1u32)); - let x = move || { - let derive = move || { - let Foo((a, b)) = foo; - }; - }; -} diff --git a/tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-125553.rs b/tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-125553.rs new file mode 100644 index 0000000000000..052b82a4056eb --- /dev/null +++ b/tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-125553.rs @@ -0,0 +1,26 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #125553 +//@[next] check-pass +//@ edition:2021 + +#![feature(type_alias_impl_trait)] + +#[derive(Copy, Clone)] +struct Foo(i32); + +// This ICEd during MIR building with the old solver. It's fixed by normalizing +// opaque types with the new solver. + +fn main() { + type T = impl Copy; + let foo: T = Foo(1); + let x = move || { + let derive = move || { + let Foo(a) = foo; + }; + }; +} From ee6d48c3516e92567dd808b0efeed0b474a98aa4 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 15:48:59 +0200 Subject: [PATCH 03/27] remove duplicate test --- tests/crashes/123157.rs | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 tests/crashes/123157.rs diff --git a/tests/crashes/123157.rs b/tests/crashes/123157.rs deleted file mode 100644 index d6cc55ba0524e..0000000000000 --- a/tests/crashes/123157.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ known-bug: #123157 -//@ edition:2021 -#![feature(type_alias_impl_trait)] - -#[derive(Copy, Clone)] -struct Foo((u32, u32)); - -fn main() { - type T = impl Copy; - let foo: T = Foo((1u32, 2u32)); - let x = move || { - let x = move || { - let Foo((a, b)) = foo; - }; - }; -} From d84ec36d7226784bd3cf2962dac72c2eb695640f Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 16:00:02 +0200 Subject: [PATCH 04/27] more things which no longer ICE --- tests/crashes/131886.rs | 15 ----------- .../trait-upcasting-131886.next.stderr | 20 +++++++++++++++ .../trait-upcasting-131886.rs | 25 +++++++++++++++++++ 3 files changed, 45 insertions(+), 15 deletions(-) delete mode 100644 tests/crashes/131886.rs create mode 100644 tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.next.stderr create mode 100644 tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.rs diff --git a/tests/crashes/131886.rs b/tests/crashes/131886.rs deleted file mode 100644 index 16cb815f1c223..0000000000000 --- a/tests/crashes/131886.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ known-bug: #131886 -//@ compile-flags: -Zvalidate-mir -#![feature(type_alias_impl_trait)] - -type Tait = impl Sized; - -trait Foo<'a>: Bar<'a, 'a, Tait> {} -trait Bar<'a, 'b, T> {} - -#[define_opaque(Tait)] -fn test_correct3<'a>(x: &dyn Foo<'a>, _: Tait) { - let _ = x as &dyn Bar<'_, '_, ()>; -} - -fn main() {} diff --git a/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.next.stderr b/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.next.stderr new file mode 100644 index 0000000000000..e46f78337a6f3 --- /dev/null +++ b/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.next.stderr @@ -0,0 +1,20 @@ +error[E0391]: cycle detected when computing type of `Tait::{opaque#0}` + --> $DIR/trait-upcasting-131886.rs:15:13 + | +LL | type Tait = impl Sized; + | ^^^^^^^^^^ + | + = note: ...which requires computing type of opaque `Tait::{opaque#0}`... +note: ...which requires borrow-checking `test_correct3`... + --> $DIR/trait-upcasting-131886.rs:21:1 + | +LL | fn test_correct3(x: &dyn Foo) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which requires promoting constants in MIR for `test_correct3`... + = note: ...which again requires computing type of `Tait::{opaque#0}`, completing the cycle + = note: cycle used when checking that `Tait::{opaque#0}` is well-formed + = note: for more information, see and + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.rs b/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.rs new file mode 100644 index 0000000000000..3f506a7f5f65e --- /dev/null +++ b/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.rs @@ -0,0 +1,25 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[next] known-bug: trait-system-refactor-initiative#303 +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #131886 +//@ compile-flags: -Zvalidate-mir +#![feature(type_alias_impl_trait)] + +// This ICEd in MIR validation with the old solver. It's fixed by normalizing +// opaque types with the new solver. This should compile, but currently fails +// with a query cycle error. + +type Tait = impl Sized; + +trait Foo: Bar {} +trait Bar {} + +#[define_opaque(Tait)] +fn test_correct3(x: &dyn Foo) { + _ = x as &dyn Bar<()>; +} + +fn main() {} From b7763ca1e0a2f5cc0e69faacb7b37463370b3eed Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 16:05:20 +0200 Subject: [PATCH 05/27] more next-solver crashes migration --- tests/crashes/135617.rs | 13 ---------- ...normalize-fully-concrete-const.next.stderr | 9 +++++++ .../cant-normalize-fully-concrete-const.rs | 24 +++++++++++++++++++ 3 files changed, 33 insertions(+), 13 deletions(-) delete mode 100644 tests/crashes/135617.rs create mode 100644 tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.next.stderr create mode 100644 tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.rs diff --git a/tests/crashes/135617.rs b/tests/crashes/135617.rs deleted file mode 100644 index ac524b823a089..0000000000000 --- a/tests/crashes/135617.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ known-bug: #135617 -trait Project { - const ASSOC: usize; -} - -fn foo() -where - for<'a> (): Project, -{ - [(); <() as Project>::ASSOC]; -} - -pub fn main() {} diff --git a/tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.next.stderr b/tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.next.stderr new file mode 100644 index 0000000000000..ba1b523146c51 --- /dev/null +++ b/tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.next.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/cant-normalize-fully-concrete-const.rs:20:6 + | +LL | [(); <() as Project>::ASSOC]; + | ^^ cannot infer the value of the constant `_` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.rs b/tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.rs new file mode 100644 index 0000000000000..3ca4976b19195 --- /dev/null +++ b/tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.rs @@ -0,0 +1,24 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #135617 + +// The bound `for<'a> (): Project` prevents us from normalizing the +// array length. This caused and ICE with the new solver. The actual +// behavior doesn't really matter here as long as it doesn't ICE. + +trait Project { + const ASSOC: usize; +} + +fn foo() +where + for<'a> (): Project, +{ + [(); <() as Project>::ASSOC]; + //[next]~^ ERROR: type annotations needed +} + +pub fn main() {} From e79214f82e6e69b83c97b61cbee6b99e9b5cd96c Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 16:23:11 +0200 Subject: [PATCH 06/27] more crashes tests --- .../old-solver-hr-alias-norm-not-idempotent.rs} | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) rename tests/{crashes/129372.rs => ui/traits/next-solver/normalize/old-solver-hr-alias-norm-not-idempotent.rs} (63%) diff --git a/tests/crashes/129372.rs b/tests/ui/traits/next-solver/normalize/old-solver-hr-alias-norm-not-idempotent.rs similarity index 63% rename from tests/crashes/129372.rs rename to tests/ui/traits/next-solver/normalize/old-solver-hr-alias-norm-not-idempotent.rs index 824e6fbfc4dd0..ae407a91a0da7 100644 --- a/tests/crashes/129372.rs +++ b/tests/ui/traits/next-solver/normalize/old-solver-hr-alias-norm-not-idempotent.rs @@ -1,7 +1,19 @@ -//@ known-bug: #129372 +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[next] build-pass +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] build-fail +//@[old] known-bug: #129372 //@ compile-flags: -Cdebuginfo=2 -Copt-level=0 //@ ignore-backends: gcc +// Regression test for #129372. With the old solver normalizing +// the output of `v.method()` ended up not fully normalizing some +// higher-ranked associated type. This then resulted in some mismatch +// later on. Fixed by the new trait solver. + pub struct Wrapper(T); struct Struct; From be29dc2296b4b96b617751a6329ed34d86170e91 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 16:29:45 +0200 Subject: [PATCH 07/27] more tests :3 --- tests/crashes/134838.rs | 14 ----------- .../field-access-on-type-ascription-134838.rs | 24 +++++++++++++++++++ 2 files changed, 24 insertions(+), 14 deletions(-) delete mode 100644 tests/crashes/134838.rs create mode 100644 tests/ui/impl-trait/normalize-hir-typeck/field-access-on-type-ascription-134838.rs diff --git a/tests/crashes/134838.rs b/tests/crashes/134838.rs deleted file mode 100644 index ac8af09b31bbd..0000000000000 --- a/tests/crashes/134838.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ known-bug: #134838 -#![feature(type_ascription)] -#![allow(dead_code)] - -struct Ty(()); - -fn mk() -> impl Sized { - if false { - let _ = type_ascribe!(mk(), Ty).0; - } - Ty(()) -} - -fn main() {} diff --git a/tests/ui/impl-trait/normalize-hir-typeck/field-access-on-type-ascription-134838.rs b/tests/ui/impl-trait/normalize-hir-typeck/field-access-on-type-ascription-134838.rs new file mode 100644 index 0000000000000..ad8036bf5103d --- /dev/null +++ b/tests/ui/impl-trait/normalize-hir-typeck/field-access-on-type-ascription-134838.rs @@ -0,0 +1,24 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[next] check-pass +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #134838 +#![feature(type_ascription)] +#![allow(dead_code)] + +// Regression test for #134838. This ICEd during MIR borrowck with the +// old solver. Fixed by eagerly normalizing opaque types with the new +// solver. + +struct Ty(()); + +fn mk() -> impl Sized { + if false { + let _ = type_ascribe!(mk(), Ty).0; + } + Ty(()) +} + +fn main() {} From 88cd166aaebafa2f2eb83cfb1373dab327573bd9 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 16:37:57 +0200 Subject: [PATCH 08/27] one more crashes test --- ...old-solver-hr-alias-norm-not-idempotent-129372.rs} | 0 ...old-solver-hr-alias-norm-not-idempotent-131373.rs} | 11 ++++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) rename tests/ui/traits/next-solver/normalize/{old-solver-hr-alias-norm-not-idempotent.rs => old-solver-hr-alias-norm-not-idempotent-129372.rs} (100%) rename tests/{crashes/131373.rs => ui/traits/next-solver/normalize/old-solver-hr-alias-norm-not-idempotent-131373.rs} (61%) diff --git a/tests/ui/traits/next-solver/normalize/old-solver-hr-alias-norm-not-idempotent.rs b/tests/ui/traits/next-solver/normalize/old-solver-hr-alias-norm-not-idempotent-129372.rs similarity index 100% rename from tests/ui/traits/next-solver/normalize/old-solver-hr-alias-norm-not-idempotent.rs rename to tests/ui/traits/next-solver/normalize/old-solver-hr-alias-norm-not-idempotent-129372.rs diff --git a/tests/crashes/131373.rs b/tests/ui/traits/next-solver/normalize/old-solver-hr-alias-norm-not-idempotent-131373.rs similarity index 61% rename from tests/crashes/131373.rs rename to tests/ui/traits/next-solver/normalize/old-solver-hr-alias-norm-not-idempotent-131373.rs index 661fecd7620b8..b2d0010289909 100644 --- a/tests/crashes/131373.rs +++ b/tests/ui/traits/next-solver/normalize/old-solver-hr-alias-norm-not-idempotent-131373.rs @@ -1,4 +1,13 @@ -//@ known-bug: #131373 +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[next] build-pass +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #131373 + +// Regression test for #131373. The old solver didn't fully normalize +// aliases with escaping bound vars, resulting in an ICE in MIR borrowck. trait LockReference: 'static { type Ref<'a>; From 24adadcc9500ba6f51af67108d1abbb1477f93a1 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 16:52:35 +0200 Subject: [PATCH 09/27] remove duplicate test --- tests/crashes/136666.rs | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 tests/crashes/136666.rs diff --git a/tests/crashes/136666.rs b/tests/crashes/136666.rs deleted file mode 100644 index 5cfed65fdf91a..0000000000000 --- a/tests/crashes/136666.rs +++ /dev/null @@ -1,36 +0,0 @@ -//@ known-bug: #136666 -// Needed so that rust can infer that the A in what() is &() -trait IsRef {} -struct Dummy; -impl<'a> IsRef<&'a ()> for Dummy {} - -trait WithLifetime { - type Output<'a>; -} -impl<'t> WithLifetime for &'t () { - type Output<'a> = &'a (); -} - -// Needed to prevent the two Foo impls from overlapping -struct Wrap(A); - -trait Unimplemented {} - -trait Foo {} -impl Foo for T where T: Unimplemented {} -impl Foo for Wrap -where - Dummy: IsRef, - for<'a> A: WithLifetime = A>, -{ -} - -fn what() -where - Wrap: Foo, -{ -} - -fn main() { - what(); -} From 9bf73a1322d2bbc79d55434ced46c08e3b4d4348 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 16:57:58 +0200 Subject: [PATCH 10/27] more crashes tests --- tests/crashes/127033.rs | 18 ----------- ...ing-use-return-hir-typeck-ty-ice-127033.rs | 32 +++++++++++++++++++ 2 files changed, 32 insertions(+), 18 deletions(-) delete mode 100644 tests/crashes/127033.rs create mode 100644 tests/ui/impl-trait/non-defining-uses/no-defining-use-return-hir-typeck-ty-ice-127033.rs diff --git a/tests/crashes/127033.rs b/tests/crashes/127033.rs deleted file mode 100644 index 52b880e4859b8..0000000000000 --- a/tests/crashes/127033.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ known-bug: #127033 -//@ edition: 2021 - -pub trait RaftLogStorage { - fn save_vote(vote: ()) -> impl std::future::Future + Send; -} - -struct X; -impl RaftLogStorage for X { - fn save_vote(vote: ()) -> impl std::future::Future { - loop {} - async { - vote - } - } -} - -fn main() {} diff --git a/tests/ui/impl-trait/non-defining-uses/no-defining-use-return-hir-typeck-ty-ice-127033.rs b/tests/ui/impl-trait/non-defining-uses/no-defining-use-return-hir-typeck-ty-ice-127033.rs new file mode 100644 index 0000000000000..4b99ff285b525 --- /dev/null +++ b/tests/ui/impl-trait/non-defining-uses/no-defining-use-return-hir-typeck-ty-ice-127033.rs @@ -0,0 +1,32 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[next] check-pass +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #127033 +//@ edition: 2021 + +// Regression test for #127033. In the old solver this test only constrained +// the RPIT in dead code, causing MIR typeck to not define it at all. +// +// This then caused us to use the type inferred by HIR typeck, later resulting in +// ICE when leaking `'erased` to parts of the compiler which didn't expect it. +// +// cc trait-system-refactor-initiative#170 + +pub trait RaftLogStorage { + fn save_vote(vote: ()) -> impl std::future::Future + Send; +} + +struct X; +impl RaftLogStorage for X { + fn save_vote(vote: ()) -> impl std::future::Future { + loop {} + async { + vote + } + } +} + +fn main() {} From c9304053b4e1722ee7c470300dc3d2762744c115 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 17:09:26 +0200 Subject: [PATCH 11/27] remove duplicate crashes test --- tests/crashes/130797.rs | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 tests/crashes/130797.rs diff --git a/tests/crashes/130797.rs b/tests/crashes/130797.rs deleted file mode 100644 index e9c877d92a6e9..0000000000000 --- a/tests/crashes/130797.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ known-bug: #130797 - -trait Transform { - type Output<'a>; -} -trait Propagate {} -trait AddChild { - fn add_child(&self) {} -} - -pub struct Node(T); -impl AddChild Propagate>>> for Node where T: Transform {} - -fn make_graph_root() { - Node(Dummy).add_child() -} - -struct Dummy; -impl Transform for Dummy { - type Output<'a> = (); -} - -pub fn main() {} From 7400ef05edeec5b99da881ac70f021c914cb32e8 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 17:44:13 +0200 Subject: [PATCH 12/27] continue crashes triage --- tests/crashes/135122.rs | 24 ----------- ...results-in-unconstrained-infer.next.stderr | 41 +++++++++++++++++++ .../success-results-in-unconstrained-infer.rs | 38 +++++++++++++++++ 3 files changed, 79 insertions(+), 24 deletions(-) delete mode 100644 tests/crashes/135122.rs create mode 100644 tests/ui/traits/next-solver/normalize/success-results-in-unconstrained-infer.next.stderr create mode 100644 tests/ui/traits/next-solver/normalize/success-results-in-unconstrained-infer.rs diff --git a/tests/crashes/135122.rs b/tests/crashes/135122.rs deleted file mode 100644 index 77d943f23b47e..0000000000000 --- a/tests/crashes/135122.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ known-bug: #135122 -trait Add { - type Output; - fn add(_: (), _: Self::Output) {} -} - -trait IsSame { - type Assoc; -} - -trait Data { - type Elem; -} - -impl IsSame for f32 where f32: IsSame {} - -impl Add for i64 -where - f32: IsSame, - i8: Data, -{ - type Output = >::Assoc; - fn add(_: Data, _: Self::Output) {} -} diff --git a/tests/ui/traits/next-solver/normalize/success-results-in-unconstrained-infer.next.stderr b/tests/ui/traits/next-solver/normalize/success-results-in-unconstrained-infer.next.stderr new file mode 100644 index 0000000000000..ab3183f129bc1 --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/success-results-in-unconstrained-infer.next.stderr @@ -0,0 +1,41 @@ +error[E0425]: cannot find type `Missing` in this scope + --> $DIR/success-results-in-unconstrained-infer.rs:35:15 + | +LL | fn add(_: Missing, _: Self::Output) {} + | ^^^^^^^ not found in this scope + +error[E0046]: not all trait items implemented, missing: `Assoc` + --> $DIR/success-results-in-unconstrained-infer.rs:25:1 + | +LL | type Assoc; + | ---------- `Assoc` from trait +... +LL | impl IsSame for f32 where f32: IsSame {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Assoc` in implementation + +error[E0207]: the type parameter `B` is not constrained by the impl trait, self type, or predicates + --> $DIR/success-results-in-unconstrained-infer.rs:25:6 + | +LL | impl IsSame for f32 where f32: IsSame {} + | ^ unconstrained type parameter + +error[E0277]: the trait bound `i8: Data` is not satisfied + --> $DIR/success-results-in-unconstrained-infer.rs:31:5 + | +LL | i8: Data, + | ^^^^^^^^^^^^^^^^^^ the trait `Data` is not implemented for `i8` + | +help: this trait has no implementations, consider adding one + --> $DIR/success-results-in-unconstrained-infer.rs:21:1 + | +LL | trait Data { + | ^^^^^^^^^^ +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0046, E0207, E0277, E0425. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/traits/next-solver/normalize/success-results-in-unconstrained-infer.rs b/tests/ui/traits/next-solver/normalize/success-results-in-unconstrained-infer.rs new file mode 100644 index 0000000000000..c0bac5c19fb5c --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/success-results-in-unconstrained-infer.rs @@ -0,0 +1,38 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #135122 + +// A regression test for #135122. The old solver normalized `::Output` to +// an inference variable without having any stalled or failed obligation. This caused +// us to then compute the implied bounds for that inference variable, causing an ICE. + +trait Add { + type Output; + fn add(_: (), _: Self::Output) {} +} + +trait IsSame { + type Assoc; +} + +trait Data { + type Elem; +} + +impl IsSame for f32 where f32: IsSame {} +//[next]~^ ERROR: not all trait items implemented, missing: `Assoc` +//[next]~| ERROR: the type parameter `B` is not constrained by the impl trait, self type, or predicates +impl Add for i64 +where + f32: IsSame, + i8: Data, + //[next]~^ ERROR: the trait bound `i8: Data` is not satisfied +{ + type Output = >::Assoc; + fn add(_: Missing, _: Self::Output) {} + //[next]~^ ERROR: cannot find type `Missing` in this scope +} +fn main() {} From c98419234ad87bf48df513db5fc427b68a8a6656 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 23:22:24 +0200 Subject: [PATCH 13/27] crashes issue triage --- .../old-solver-projection-cache-bug-135718.rs} | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) rename tests/{crashes/135718.rs => ui/traits/next-solver/normalize/old-solver-projection-cache-bug-135718.rs} (66%) diff --git a/tests/crashes/135718.rs b/tests/ui/traits/next-solver/normalize/old-solver-projection-cache-bug-135718.rs similarity index 66% rename from tests/crashes/135718.rs rename to tests/ui/traits/next-solver/normalize/old-solver-projection-cache-bug-135718.rs index c0e628f4c46c3..839579b81c81b 100644 --- a/tests/crashes/135718.rs +++ b/tests/ui/traits/next-solver/normalize/old-solver-projection-cache-bug-135718.rs @@ -1,4 +1,13 @@ -//@ known-bug: #135718 +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[next] check-pass +//@[old] build-fail +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug:: #135718 + +// A regression test for a caching bug with the old trait solver. struct Equal; From 5975e497d22b8e2e2cad9c933750de8560bdf91a Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 23:34:59 +0200 Subject: [PATCH 14/27] add crashes test --- tests/crashes/139381.rs | 13 ---------- ...ect-skip-binder-for-item-bound.next.stderr | 25 +++++++++++++++++++ .../incorrect-skip-binder-for-item-bound.rs | 24 ++++++++++++++++++ 3 files changed, 49 insertions(+), 13 deletions(-) delete mode 100644 tests/crashes/139381.rs create mode 100644 tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.next.stderr create mode 100644 tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.rs diff --git a/tests/crashes/139381.rs b/tests/crashes/139381.rs deleted file mode 100644 index 6757b584e82a1..0000000000000 --- a/tests/crashes/139381.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ known-bug: #139381 -//@ needs-rustc-debug-assertions -trait A<'a> { - type Assoc: ?Sized; -} - -impl<'a> A<'a> for () { - type Assoc = &'a (); -} - -fn hello() -> impl for<'a> A<'a, Assoc: Into + 'static + Copy> { - () -} diff --git a/tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.next.stderr b/tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.next.stderr new file mode 100644 index 0000000000000..edb3f36cd7560 --- /dev/null +++ b/tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.next.stderr @@ -0,0 +1,25 @@ +error[E0277]: the trait bound `for<'a> u8: From<&'a ()>` is not satisfied + --> $DIR/incorrect-skip-binder-for-item-bound.rs:19:15 + | +LL | fn hello() -> impl for<'a> A<'a, Assoc: Into + 'static + Copy> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> From<&'a ()>` is not implemented for `u8` + | +help: `u8` implements trait `From` + --> $SRC_DIR/core/src/convert/num.rs:LL:COL + | + = note: `From` + ::: $SRC_DIR/core/src/convert/num.rs:LL:COL + | + = note: in this macro invocation + --> $SRC_DIR/core/src/ascii/ascii_char.rs:LL:COL + | + = note: `From` + ::: $SRC_DIR/core/src/ascii/ascii_char.rs:LL:COL + | + = note: in this macro invocation + = note: required for `&'a ()` to implement `for<'a> Into` + = note: this error originates in the macro `impl_from_bool` which comes from the expansion of the macro `into_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.rs b/tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.rs new file mode 100644 index 0000000000000..65a7d9442311e --- /dev/null +++ b/tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.rs @@ -0,0 +1,24 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #139381 +//@ needs-rustc-debug-assertions + +// An ICE caused by an incorrect `skip_binder()` in diagnostics code, see #139381. + +trait A<'a> { + type Assoc: ?Sized; +} + +impl<'a> A<'a> for () { + type Assoc = &'a (); +} + +fn hello() -> impl for<'a> A<'a, Assoc: Into + 'static + Copy> { + //[next]~^ ERROR: the trait bound `for<'a> u8: From<&'a ()>` is not satisfied + () +} + +fn main() {} From d0acaae5ae9c68937a0b0751d1eba941ff4d9c50 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 5 Oct 2026 23:58:50 +0200 Subject: [PATCH 15/27] more crashes tests --- tests/crashes/138707.rs | 37 ------------ ...complete-guidance-normalize-impl-header.rs | 57 +++++++++++++++++++ 2 files changed, 57 insertions(+), 37 deletions(-) delete mode 100644 tests/crashes/138707.rs create mode 100644 tests/ui/traits/next-solver/assembly/incomplete-guidance-normalize-impl-header.rs diff --git a/tests/crashes/138707.rs b/tests/crashes/138707.rs deleted file mode 100644 index 4d9a82500ec45..0000000000000 --- a/tests/crashes/138707.rs +++ /dev/null @@ -1,37 +0,0 @@ -//@ known-bug: #138707 -//@edition:2024 -//@compile-flags: --crate-type lib -use core::marker::PhantomData; - -struct LeftReflector { - _phantom: PhantomData, -} - -struct DefaultAllocator {} - -trait Allocator { - type Buffer; -} - -struct U2 {} - -impl Allocator for DefaultAllocator { - type Buffer = [u8; 2]; -} - -impl From for LeftReflector<>::Buffer> -where - DefaultAllocator: Allocator, -{ - fn from(_: R) -> Self { - todo!() - } -} - -fn ice(a: U2) -where - DefaultAllocator: Allocator, -{ - // ICE - let _ = LeftReflector::from(a); -} diff --git a/tests/ui/traits/next-solver/assembly/incomplete-guidance-normalize-impl-header.rs b/tests/ui/traits/next-solver/assembly/incomplete-guidance-normalize-impl-header.rs new file mode 100644 index 0000000000000..c2d0dd6854fab --- /dev/null +++ b/tests/ui/traits/next-solver/assembly/incomplete-guidance-normalize-impl-header.rs @@ -0,0 +1,57 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[next] check-pass +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #138707 +//@edition:2024 +//@compile-flags: --crate-type lib + +// When using the `From` impl we eagerly normalize +// `>::Buffer` before +// ever equating the impl header with the goal. Because +// of the `DefaultAllocator: Allocator`, this keeps the +// alias as rigid without actually constraining `?r` to `D` +// in the old solver. +// +// This then passes HIR typeck as constraining the `?s` of +// `LeftReflector` to an alias is fine and that alias gets +// later normalized to `()`. However, now keeping the alias in +// the impl header as rigid results in a failure when relating +// the impl header with `LeftReflector<()>` from the goal. +// +// This only passes with the new solver as we currently don't +// explicitly normalize the impl header before equating it with +// the goal, instead replacing non-rigid aliases with inference +// variables on demand. We may end up breaking this test if we +// start to eagerly normalize within the new trait solver. + +struct LeftReflector(S); +struct DefaultAllocator {} + +trait Allocator { + type Buffer; +} + +impl Allocator<()> for DefaultAllocator { + type Buffer = (); +} + + +impl From for LeftReflector<>::Buffer> +where + DefaultAllocator: Allocator, +{ + fn from(_: R) -> Self { + todo!() + } +} + +fn ice(a: ()) +where + DefaultAllocator: Allocator, +{ + // ICE + let _ = LeftReflector::from(a); +} From dcde4eeabc9a1d4e6ea18b004408af0895636ffa Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 6 Oct 2026 09:40:01 +0200 Subject: [PATCH 16/27] more crashes triage --- tests/crashes/140303.rs | 22 ---------- ...ound-holds-for-ty-error-140303.next.stderr | 10 +++++ .../trait-bound-holds-for-ty-error-140303.rs | 44 +++++++++++++++++++ 3 files changed, 54 insertions(+), 22 deletions(-) delete mode 100644 tests/crashes/140303.rs create mode 100644 tests/ui/traits/error-reporting/trait-bound-holds-for-ty-error-140303.next.stderr create mode 100644 tests/ui/traits/error-reporting/trait-bound-holds-for-ty-error-140303.rs diff --git a/tests/crashes/140303.rs b/tests/crashes/140303.rs deleted file mode 100644 index 43a20b5e58ed4..0000000000000 --- a/tests/crashes/140303.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ known-bug: #140303 -//@compile-flags: -Zvalidate-mir -use std::future::Future; -async fn a() -> impl Sized { - b(c) -} -async fn c(); // kaboom -fn b(e: d) -> impl Sized -where - d: f, -{ - || -> ::h { panic!() } -} -trait f { - type h; -} -impl f for d -where - d: Fn() -> g, - g: Future, -{ -} diff --git a/tests/ui/traits/error-reporting/trait-bound-holds-for-ty-error-140303.next.stderr b/tests/ui/traits/error-reporting/trait-bound-holds-for-ty-error-140303.next.stderr new file mode 100644 index 0000000000000..2af1d6ddb4c97 --- /dev/null +++ b/tests/ui/traits/error-reporting/trait-bound-holds-for-ty-error-140303.next.stderr @@ -0,0 +1,10 @@ +error: free function without a body + --> $DIR/trait-bound-holds-for-ty-error-140303.rs:28:1 + | +LL | async fn c(); // kaboom + | ^^^^^^^^^^^^- + | | + | help: provide a definition for the function: `{ }` + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/error-reporting/trait-bound-holds-for-ty-error-140303.rs b/tests/ui/traits/error-reporting/trait-bound-holds-for-ty-error-140303.rs new file mode 100644 index 0000000000000..dfc6349187f40 --- /dev/null +++ b/tests/ui/traits/error-reporting/trait-bound-holds-for-ty-error-140303.rs @@ -0,0 +1,44 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #140303 +//@ compile-flags: -Zvalidate-mir --emit=link +//@ edition: 2018 + +// This only ICEd with `--emit=link` while only erroring when compiled +// with `--emit=metadata`. This is necessary to compute +// `mir_drops_elaborated_and_const_checked` even though there were +// earlier errors. +// +// This ICEd during MIR validation with the old solver when normalizing +// the return type of `b(c)`. `fn c` returns `impl Future` which normalizes +// to `{type error}`. The old solver is able to prove `impl Future: Future`, +// but `{type error}: Future` results in ambiguity. +// +// The new solver instead considers `{type error}: Future` to hold. + +use std::future::Future; +struct Wrapper(T); +fn a() { + let _ = Wrapper(b(c)); +} + +async fn c(); // kaboom +//[next]~^ ERROR: free function without a body +fn b(e: T) -> impl Sized { + fn mk() -> T { todo!() } + mk::<::Assoc>() +} +trait Trait { + type Assoc; +} +impl Trait for T +where + T: Fn() -> R, + R: Future, +{ + type Assoc = (); +} +fn main() {} From 905891eddfb94143a04ad1f78fed32c4fc8315ff Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 6 Oct 2026 09:59:53 +0200 Subject: [PATCH 17/27] remove duplicate test --- tests/crashes/130524.rs | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 tests/crashes/130524.rs diff --git a/tests/crashes/130524.rs b/tests/crashes/130524.rs deleted file mode 100644 index 14d2269de5980..0000000000000 --- a/tests/crashes/130524.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ known-bug: #130524 - -trait Transform { - type Output<'a>; -} - -trait Propagate {} - -fn new_node(_c: Vec Propagate<::Output<'a>>>>) -> T { - todo!() -} - -impl Propagate for T {} -struct Noop; - -impl Transform for Noop { - type Output<'a> = (); -} - -fn main() { - let _node: Noop = new_node(vec![Box::new(Noop)]); -} From 9be63df84ffab21c006ef666887a2b849f2994a4 Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 6 Oct 2026 10:07:10 +0200 Subject: [PATCH 18/27] more crashes tests --- tests/crashes/147719.rs | 16 ---------- ...k-check-on-ambig-async-closure.next.stderr | 31 +++++++++++++++++++ ...-only-leak-check-on-ambig-async-closure.rs | 28 +++++++++++++++++ 3 files changed, 59 insertions(+), 16 deletions(-) delete mode 100644 tests/crashes/147719.rs create mode 100644 tests/ui/higher-ranked/leak-check/old-solver-only-leak-check-on-ambig-async-closure.next.stderr create mode 100644 tests/ui/higher-ranked/leak-check/old-solver-only-leak-check-on-ambig-async-closure.rs diff --git a/tests/crashes/147719.rs b/tests/crashes/147719.rs deleted file mode 100644 index d9595b8ead565..0000000000000 --- a/tests/crashes/147719.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ known-bug: #147719 -//@ edition: 2024 -trait NodeImpl {} -struct Wrap(F, P); -impl Wrap { - fn new(_: F) -> Self { - loop {} - } -} -trait Arg {} -impl NodeImpl for Wrap where A: Arg {} -impl NodeImpl for Wrap where F: Fn(&(), A) -> Fut {} -fn trigger_ice() { - let _: &dyn NodeImpl = &Wrap::<_, (i128,)>::new(async |_: &(), i128| 0); -} -fn main() {} diff --git a/tests/ui/higher-ranked/leak-check/old-solver-only-leak-check-on-ambig-async-closure.next.stderr b/tests/ui/higher-ranked/leak-check/old-solver-only-leak-check-on-ambig-async-closure.next.stderr new file mode 100644 index 0000000000000..6fda59572171b --- /dev/null +++ b/tests/ui/higher-ranked/leak-check/old-solver-only-leak-check-on-ambig-async-closure.next.stderr @@ -0,0 +1,31 @@ +error[E0277]: the trait bound `Wrap<{async closure@$DIR/old-solver-only-leak-check-on-ambig-async-closure.rs:26:20: 26:34}>: NodeImpl` is not satisfied + --> $DIR/old-solver-only-leak-check-on-ambig-async-closure.rs:26:15 + | +LL | node_impl(Wrap(async |_: &()| ())); + | --------- ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound + | | + | required by a bound introduced by this call + | +help: the trait `NodeImpl` is not implemented for `Wrap<{async closure@$DIR/old-solver-only-leak-check-on-ambig-async-closure.rs:26:20: 26:34}>` + --> $DIR/old-solver-only-leak-check-on-ambig-async-closure.rs:14:1 + | +LL | struct Wrap(F); + | ^^^^^^^^^^^^^^ +help: the trait `NodeImpl` is conditionally implemented for `Wrap` + --> $DIR/old-solver-only-leak-check-on-ambig-async-closure.rs:18:1 + | +LL | / impl NodeImpl for Wrap +LL | | where +LL | | F: Fn(&()) -> Fut, + | |___________________---^ + | | + | unsatisfied requirement introduced here: `for<'a> <_ as FnOnce<(&'a (),)>>::Output == _` +note: required by a bound in `node_impl` + --> $DIR/old-solver-only-leak-check-on-ambig-async-closure.rs:24:17 + | +LL | fn node_impl(_: T) {} + | ^^^^^^^^ required by this bound in `node_impl` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/leak-check/old-solver-only-leak-check-on-ambig-async-closure.rs b/tests/ui/higher-ranked/leak-check/old-solver-only-leak-check-on-ambig-async-closure.rs new file mode 100644 index 0000000000000..e30d7bcc23ef7 --- /dev/null +++ b/tests/ui/higher-ranked/leak-check/old-solver-only-leak-check-on-ambig-async-closure.rs @@ -0,0 +1,28 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #147719 +//@ edition: 2024 + +// A variant of `old-solver-only-leak-check-on-ambig.rs` which +// relies on us deferring the inference of async closure upvars. +// `Fut` is higher ranked as it ends up capturing the function +// argument. + +struct Wrap(F); +trait NotImplemented {} +trait NodeImpl {} +impl NodeImpl for T {} +impl NodeImpl for Wrap +where + F: Fn(&()) -> Fut, +{ +} + +fn node_impl(_: T) {} +fn main() { + node_impl(Wrap(async |_: &()| ())); + //[next]~^ ERROR: the trait bound +} From 7b5a60033d6734dae409f4cceb2e6715222bb49d Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 6 Oct 2026 10:12:34 +0200 Subject: [PATCH 19/27] yeet duplicate test --- tests/crashes/148094.rs | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 tests/crashes/148094.rs diff --git a/tests/crashes/148094.rs b/tests/crashes/148094.rs deleted file mode 100644 index 7c08240a198c5..0000000000000 --- a/tests/crashes/148094.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: #148094 -//@ compile-flags: -Zvalidate-mir -#![feature(type_alias_impl_trait)] -type Tait = impl Sized; -trait Foo: Bar {} -trait Bar {} -#[define_opaque(Tait)] -fn test_correct3(x: &dyn Foo) -> &dyn Bar<()> { - x -} -fn main() {} From 9883d34bc0cbea1171f6aaf8f4ceeeca51ecd094 Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 6 Oct 2026 10:14:59 +0200 Subject: [PATCH 20/27] yeet duplicate test --- tests/crashes/139120.rs | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 tests/crashes/139120.rs diff --git a/tests/crashes/139120.rs b/tests/crashes/139120.rs deleted file mode 100644 index f946f010c44ef..0000000000000 --- a/tests/crashes/139120.rs +++ /dev/null @@ -1,29 +0,0 @@ -//@ known-bug: #139120 - - - -pub trait Foo { - type Bar<'a>; -} - -pub struct FooImpl {} - -impl Foo for FooImpl { - type Bar<'a> = (); -} - -pub trait FooFn { - fn bar(&self); -} - -impl FooFn for fn(T, T::Bar<'_>) { - fn bar(&self) {} -} - -fn foo(f: fn(T, T::Bar<'_>)) { - let _: &dyn FooFn = &f; -} - -fn main() { - foo(|_: FooImpl, _| {}); -} From 743fe790d281bde4a44a7ec7a5effba28ee207ab Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 6 Oct 2026 10:38:12 +0200 Subject: [PATCH 21/27] add regression test --- tests/crashes/146965.rs | 29 -------------- .../mir-inlining-ice-146965.rs | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+), 29 deletions(-) delete mode 100644 tests/crashes/146965.rs create mode 100644 tests/ui/traits/next-solver/normalization-shadowing/mir-inlining-ice-146965.rs diff --git a/tests/crashes/146965.rs b/tests/crashes/146965.rs deleted file mode 100644 index d663ccb358178..0000000000000 --- a/tests/crashes/146965.rs +++ /dev/null @@ -1,29 +0,0 @@ -//@ known-bug: #146965 -//@ compile-flags: --crate-type lib -C opt-level=3 - -fn conjure() -> T { - panic!() -} - -pub trait Ring { - type Element; -} -impl Ring for T { - type Element = u16; -} - -// Removing the : Ring bound makes it not ICE -fn map_coeff(f: impl Fn(::Element)) { - let c = conjure::<::Element>(); - f(c); -} - -// Adding a : Ring bound makes it not ICE -fn gcd() { - map_coeff::(|_: u16| {}); -} - -// Removing the : Ring bound makes it not ICE -pub fn bivariate_factorization() { - gcd::(); -} diff --git a/tests/ui/traits/next-solver/normalization-shadowing/mir-inlining-ice-146965.rs b/tests/ui/traits/next-solver/normalization-shadowing/mir-inlining-ice-146965.rs new file mode 100644 index 0000000000000..dc688786888e4 --- /dev/null +++ b/tests/ui/traits/next-solver/normalization-shadowing/mir-inlining-ice-146965.rs @@ -0,0 +1,39 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[next] build-pass +//@[old] build-fail +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #146965 +//@ compile-flags: --crate-type lib -C opt-level=3 + +// A regression test for #146965. When considering to inline `fn no_bound` +// into `fn optimize_me` we check `no_bound::{closure}: FnOnce(::Element)`. +// +// In `fn no_bound` we can normalize `::Element` to `u16` while the +// `T: Ring` bound in `fn optimize_me` means the associated type stays rigid +// again. This then causes us to fail to prove this where-bound. +// +// This is the case with both solvers, the new solver accepts it gracefully, while +// the old solver ICEd in `fn codegen_select_candidate`. + +pub trait Ring { + type Element; +} +impl Ring for T { + type Element = u16; +} + +fn and_rigid_again(f: impl FnOnce(::Element)) { + fn mk() -> T { todo!() } + f(mk()); +} + +fn no_bound() { + and_rigid_again::(|_: u16| {}); +} + +pub fn optimize_me() { + no_bound::(); +} From 60e0ae0beaff04f683bd38aca952bbe1e166f061 Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 6 Oct 2026 10:49:56 +0200 Subject: [PATCH 22/27] more crashes tests --- tests/crashes/149015.rs | 10 --- ...l-to-normalize-own-self-ty-ice.next.stderr | 65 +++++++++++++++++++ .../use-impl-to-normalize-own-self-ty-ice.rs | 24 +++++++ 3 files changed, 89 insertions(+), 10 deletions(-) delete mode 100644 tests/crashes/149015.rs create mode 100644 tests/ui/traits/next-solver/cycles/use-impl-to-normalize-own-self-ty-ice.next.stderr create mode 100644 tests/ui/traits/next-solver/cycles/use-impl-to-normalize-own-self-ty-ice.rs diff --git a/tests/crashes/149015.rs b/tests/crashes/149015.rs deleted file mode 100644 index c262dc7d47fe3..0000000000000 --- a/tests/crashes/149015.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ known-bug: #149015 -trait Trait1 { - type Assoc; -} - -trait Trait2 {} - -impl Trait1 for ::Assoc { - type Assoc = (); -} diff --git a/tests/ui/traits/next-solver/cycles/use-impl-to-normalize-own-self-ty-ice.next.stderr b/tests/ui/traits/next-solver/cycles/use-impl-to-normalize-own-self-ty-ice.next.stderr new file mode 100644 index 0000000000000..d327a843ab611 --- /dev/null +++ b/tests/ui/traits/next-solver/cycles/use-impl-to-normalize-own-self-ty-ice.next.stderr @@ -0,0 +1,65 @@ +error[E0277]: the trait bound `&'static (): Trait` is not satisfied + --> $DIR/use-impl-to-normalize-own-self-ty-ice.rs:15:16 + | +LL | impl Trait for <&'static () as Trait>::Assoc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `&'static ()` + | +help: the trait `Trait` is implemented for `<&'static () as Trait>::Assoc` + --> $DIR/use-impl-to-normalize-own-self-ty-ice.rs:15:1 + | +LL | impl Trait for <&'static () as Trait>::Assoc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `&'static (): Trait` is not satisfied + --> $DIR/use-impl-to-normalize-own-self-ty-ice.rs:15:6 + | +LL | impl Trait for <&'static () as Trait>::Assoc { + | ^^^^^ the trait `Trait` is not implemented for `&'static ()` + | +help: the trait `Trait` is implemented for `<&'static () as Trait>::Assoc` + --> $DIR/use-impl-to-normalize-own-self-ty-ice.rs:15:1 + | +LL | impl Trait for <&'static () as Trait>::Assoc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `&'static (): Trait` is not satisfied + --> $DIR/use-impl-to-normalize-own-self-ty-ice.rs:20:18 + | +LL | type Assoc = (); + | ^^ the trait `Trait` is not implemented for `&'static ()` + | +help: the trait `Trait` is implemented for `<&'static () as Trait>::Assoc` + --> $DIR/use-impl-to-normalize-own-self-ty-ice.rs:15:1 + | +LL | impl Trait for <&'static () as Trait>::Assoc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `&'static (): Trait` is not satisfied + --> $DIR/use-impl-to-normalize-own-self-ty-ice.rs:15:16 + | +LL | impl Trait for <&'static () as Trait>::Assoc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `&'static ()` + | +help: the trait `Trait` is implemented for `<&'static () as Trait>::Assoc` + --> $DIR/use-impl-to-normalize-own-self-ty-ice.rs:15:1 + | +LL | impl Trait for <&'static () as Trait>::Assoc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0277]: the trait bound `&'static (): Trait` is not satisfied + --> $DIR/use-impl-to-normalize-own-self-ty-ice.rs:15:16 + | +LL | impl Trait for <&'static () as Trait>::Assoc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `&'static ()` + | +help: the trait `Trait` is implemented for `<&'static () as Trait>::Assoc` + --> $DIR/use-impl-to-normalize-own-self-ty-ice.rs:15:1 + | +LL | impl Trait for <&'static () as Trait>::Assoc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/cycles/use-impl-to-normalize-own-self-ty-ice.rs b/tests/ui/traits/next-solver/cycles/use-impl-to-normalize-own-self-ty-ice.rs new file mode 100644 index 0000000000000..4cd1a1b795e34 --- /dev/null +++ b/tests/ui/traits/next-solver/cycles/use-impl-to-normalize-own-self-ty-ice.rs @@ -0,0 +1,24 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #149015 + +// A regression test for #149015. This ICEd in `fn rematch_impl` due to +// buggy cycle handling in the old solver. + +trait Trait { + type Assoc; +} + +impl Trait for <&'static () as Trait>::Assoc { +//[next]~^ ERROR: the trait bound `&'static (): Trait` is not satisfied +//[next]~| ERROR: the trait bound `&'static (): Trait` is not satisfied +//[next]~| ERROR: the trait bound `&'static (): Trait` is not satisfied +//[next]~| ERROR: the trait bound `&'static (): Trait` is not satisfied + type Assoc = (); + //[next]~^ ERROR: the trait bound `&'static (): Trait` is not satisfied +} + +fn main() {} From 9e42fc772e7c7caabcb657cc7b218185e2889979 Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 6 Oct 2026 11:09:28 +0200 Subject: [PATCH 23/27] add crashes test --- tests/crashes/148095.rs | 11 -- ...-old-solver-caching-ice-148095.next.stderr | 126 ++++++++++++++++++ ...incorrect-old-solver-caching-ice-148095.rs | 33 +++++ 3 files changed, 159 insertions(+), 11 deletions(-) delete mode 100644 tests/crashes/148095.rs create mode 100644 tests/ui/traits/next-solver/overflow/incorrect-old-solver-caching-ice-148095.next.stderr create mode 100644 tests/ui/traits/next-solver/overflow/incorrect-old-solver-caching-ice-148095.rs diff --git a/tests/crashes/148095.rs b/tests/crashes/148095.rs deleted file mode 100644 index 43be99254164f..0000000000000 --- a/tests/crashes/148095.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: #148095 -use std::ops::Mul; - -struct Quantity(S); -impl Mul>::Output>> for f32 -where - Quantity: -{ - type Output = (); - fn mul(self, _: Quantity<>::Output>) {} -} diff --git a/tests/ui/traits/next-solver/overflow/incorrect-old-solver-caching-ice-148095.next.stderr b/tests/ui/traits/next-solver/overflow/incorrect-old-solver-caching-ice-148095.next.stderr new file mode 100644 index 0000000000000..c285c42d380e8 --- /dev/null +++ b/tests/ui/traits/next-solver/overflow/incorrect-old-solver-caching-ice-148095.next.stderr @@ -0,0 +1,126 @@ +error[E0207]: the type parameter `S` is not constrained by the impl trait, self type, or predicates + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:25:6 + | +LL | impl Mul>::Output>> for f32 + | ^ unconstrained type parameter + +error[E0277]: cannot multiply `f32` by `S` + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:25:13 + | +LL | impl Mul>::Output>> for f32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `f32 * S` + | + = help: the trait `Mul` is not implemented for `f32` +help: consider extending the `where` clause, but there might be an alternative better way to express this requirement + | +LL | Quantity:, f32: Mul + | +++++++++++++ + +error[E0277]: cannot multiply `f32` by `S` + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:30:5 + | +LL | fn mul(self, _: Quantity<>::Output>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `f32 * S` + | + = help: the trait `Mul` is not implemented for `f32` +help: consider extending the `where` clause, but there might be an alternative better way to express this requirement + | +LL | Quantity:, f32: Mul + | +++++++++++++ + +error[E0276]: impl has stricter requirements than trait + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:30:5 + | +LL | fn mul(self, _: Quantity<>::Output>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `Quantity<>::Output> well-formed` + +error[E0277]: cannot multiply `f32` by `S` + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:25:13 + | +LL | impl Mul>::Output>> for f32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `f32 * S` + | + = help: the trait `Mul` is not implemented for `f32` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider extending the `where` clause, but there might be an alternative better way to express this requirement + | +LL | Quantity:, f32: Mul + | +++++++++++++ + +error[E0277]: cannot multiply `f32` by `S` + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:30:30 + | +LL | fn mul(self, _: Quantity<>::Output>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `f32 * S` + | + = help: the trait `Mul` is not implemented for `f32` +help: consider extending the `where` clause, but there might be an alternative better way to express this requirement + | +LL | Quantity:, f32: Mul + | +++++++++++++ + +error[E0277]: cannot multiply `f32` by `Quantity<>::Output>` + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:27:5 + | +LL | Quantity: + | ^^^^^^^^^^^^^^^^^^^^^^ no implementation for `f32 * Quantity<>::Output>` + | + = help: the trait `Mul>::Output>>` is not implemented for `f32` +note: required by a bound in `Quantity` + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:24:17 + | +LL | struct Quantity(S); + | ^ required by this bound in `Quantity` +help: consider extending the `where` clause, but there might be an alternative better way to express this requirement + | +LL | Quantity:, f32: Mul>::Output>> + | +++++++++++++++++++++++++++++++++++++++++++++ + +error[E0277]: cannot multiply `f32` by `S` + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:27:5 + | +LL | Quantity: + | ^^^^^^^^^^^^^^^^^^^^^^ no implementation for `f32 * S` + | + = help: the trait `Mul` is not implemented for `f32` +note: required by a bound in `Quantity` + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:24:17 + | +LL | struct Quantity(S); + | ^ required by this bound in `Quantity` +help: consider extending the `where` clause, but there might be an alternative better way to express this requirement + | +LL | Quantity:, f32: Mul + | +++++++++++++ + +error[E0277]: cannot multiply `f32` by `S` + | + = help: the trait `Mul` is not implemented for `f32` +help: consider extending the `where` clause, but there might be an alternative better way to express this requirement + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:27:28 + | +LL | Quantity:, f32: Mul + | +++++++++++++ + +error: the type `Quantity<>::Output>` is not well-formed + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:30:21 + | +LL | fn mul(self, _: Quantity<>::Output>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: cannot multiply `f32` by `S` + --> $DIR/incorrect-old-solver-caching-ice-148095.rs:30:21 + | +LL | fn mul(self, _: Quantity<>::Output>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `f32 * S` + | + = help: the trait `Mul` is not implemented for `f32` +help: consider extending the `where` clause, but there might be an alternative better way to express this requirement + | +LL | Quantity:, f32: Mul + | +++++++++++++ + +error: aborting due to 11 previous errors + +Some errors have detailed explanations: E0207, E0276, E0277. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/next-solver/overflow/incorrect-old-solver-caching-ice-148095.rs b/tests/ui/traits/next-solver/overflow/incorrect-old-solver-caching-ice-148095.rs new file mode 100644 index 0000000000000..4b0c3885ac8a9 --- /dev/null +++ b/tests/ui/traits/next-solver/overflow/incorrect-old-solver-caching-ice-148095.rs @@ -0,0 +1,33 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[next] dont-require-annotations: ERROR +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #148095 + +// A regression test for #148095. The old solver incorrectly cached +// a result from in one context and then used that result in a different +// context, triggering an assert. +// +// More specifically, when in `self.query_mode == TraitQueryMode::Canonical`, +// `WfPredicates::normalize` creates a separate `SelectionContext` for +// normalization which is not in that mode. That then ICEs when accessing +// a cache entry from the `infcx`-local cache, which also caches canonical +// overflow. +// +// This test results in a lot of errors with the new solver, so lets not add +// explicit annotations here. + +use std::ops::Mul; + +struct Quantity(S); +impl Mul>::Output>> for f32 +where + Quantity: +{ + type Output = (); + fn mul(self, _: Quantity<>::Output>) {} +} + +fn main() {} From baa250343803858aad84aad811b0c8ab34dcbd0a Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 6 Oct 2026 11:12:13 +0200 Subject: [PATCH 24/27] yeet duplicate test --- tests/crashes/150263.rs | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 tests/crashes/150263.rs diff --git a/tests/crashes/150263.rs b/tests/crashes/150263.rs deleted file mode 100644 index 44d0fdbdda9b0..0000000000000 --- a/tests/crashes/150263.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ known-bug: #150263 -//@ compile-flags: --crate-type lib -C opt-level=3 - -pub trait Scope { - type Timestamp; -} -impl Scope for G { - type Timestamp = (); -} - -pub fn create() { - enter::(); -} - -fn enter() { - unary::(|_: ::Timestamp| {}); -} - -fn unary(constructor: impl FnOnce(G::Timestamp)) { - constructor(None.unwrap()); -} From 89242d818d6bd5a99d8dc505bb8dcc01418f1828 Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 6 Oct 2026 11:30:51 +0200 Subject: [PATCH 25/27] yeet duplicate test --- tests/crashes/150517.rs | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 tests/crashes/150517.rs diff --git a/tests/crashes/150517.rs b/tests/crashes/150517.rs deleted file mode 100644 index de14628547d28..0000000000000 --- a/tests/crashes/150517.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ known-bug: #150517 -trait Stream { - type Item; - fn next(self) -> (); -} -impl Stream for &'a () {} -impl<'a, A> Stream for <&A as Stream>::Item {} -trait StreamExt { - fn f(self) -> () - where - for<'b> &'b A: Stream, - { - self.next() - } -} From ab3e7ce856dc4c40d4f6092a47b267edb380c526 Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 6 Oct 2026 11:44:54 +0200 Subject: [PATCH 26/27] crashes migration --- tests/crashes/151069.rs | 16 ---------- .../old-solver-caching-bug-151069.next.stderr | 31 +++++++++++++++++++ .../old-solver-caching-bug-151069.rs | 27 ++++++++++++++++ 3 files changed, 58 insertions(+), 16 deletions(-) delete mode 100644 tests/crashes/151069.rs create mode 100644 tests/ui/traits/next-solver/normalize/old-solver-caching-bug-151069.next.stderr create mode 100644 tests/ui/traits/next-solver/normalize/old-solver-caching-bug-151069.rs diff --git a/tests/crashes/151069.rs b/tests/crashes/151069.rs deleted file mode 100644 index ae6f4da5c6c70..0000000000000 --- a/tests/crashes/151069.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ known-bug: #151069 -trait Trait { - type Assoc2; -} -struct Bar; -impl Trait for Bar -where - ::Assoc2: Trait, -{ - type Assoc2 = (); -} -struct Foo { - field: ::Assoc2, -} -static FOO2: &Foo = 0; -fn main() {} diff --git a/tests/ui/traits/next-solver/normalize/old-solver-caching-bug-151069.next.stderr b/tests/ui/traits/next-solver/normalize/old-solver-caching-bug-151069.next.stderr new file mode 100644 index 0000000000000..b52a8a2a424a5 --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/old-solver-caching-bug-151069.next.stderr @@ -0,0 +1,31 @@ +error[E0275]: overflow evaluating the requirement `::Assoc2 == _` + --> $DIR/old-solver-caching-bug-151069.rs:17:1 + | +LL | / impl Trait for Bar +LL | | where +LL | | ::Assoc2: Trait, + | |__________________________________^ + +error[E0275]: overflow evaluating the requirement `::Assoc2 == _` + --> $DIR/old-solver-caching-bug-151069.rs:21:5 + | +LL | type Assoc2 = (); + | ^^^^^^^^^^^ + +error[E0275]: overflow evaluating the requirement `::Assoc2 == _` + --> $DIR/old-solver-caching-bug-151069.rs:24:12 + | +LL | field: ::Assoc2, + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0275]: overflow evaluating whether `::Assoc2` is well-formed + --> $DIR/old-solver-caching-bug-151069.rs:24:12 + | +LL | field: ::Assoc2, + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0275]: overflow evaluating the requirement `::Metadata == _` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/next-solver/normalize/old-solver-caching-bug-151069.rs b/tests/ui/traits/next-solver/normalize/old-solver-caching-bug-151069.rs new file mode 100644 index 0000000000000..ffed91181042e --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/old-solver-caching-bug-151069.rs @@ -0,0 +1,27 @@ +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[next] dont-require-annotations: ERROR +//@[old] failure-status: 101 +//@[old] dont-check-compiler-stderr +//@[old] known-bug: #151069 + +// Regression test for #151069. This triggers a caching bug in the old solver, +// resulting in an ICE. IT results in a bunch of overflow errors, so let's just +// ignore the annotations here. + +trait Trait { + type Assoc2; +} +struct Bar; +impl Trait for Bar +where + ::Assoc2: Trait, +{ + type Assoc2 = (); +} +struct Foo { + field: ::Assoc2, +} +static FOO2: &Foo = 0; +fn main() {} From 579a6bdff1b5909b94ab32cab1206f556f005120 Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 6 Oct 2026 17:46:33 +0200 Subject: [PATCH 27/27] review --- .../normalize-hir-typeck/in-closure-capture-ice-125553.rs | 2 +- .../normalize-hir-typeck/switch-int-terminator-140850.rs | 2 +- tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-125553.rs b/tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-125553.rs index 052b82a4056eb..b99adadcc01f6 100644 --- a/tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-125553.rs +++ b/tests/ui/impl-trait/normalize-hir-typeck/in-closure-capture-ice-125553.rs @@ -1,10 +1,10 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver +//@[next] check-pass //@[old] failure-status: 101 //@[old] dont-check-compiler-stderr //@[old] known-bug: #125553 -//@[next] check-pass //@ edition:2021 #![feature(type_alias_impl_trait)] diff --git a/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-140850.rs b/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-140850.rs index 513e4e382a4d9..353e99315a57e 100644 --- a/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-140850.rs +++ b/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-140850.rs @@ -1,10 +1,10 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver +//@[next] check-pass //@[old] failure-status: 101 //@[old] dont-check-compiler-stderr //@[old] known-bug: #140850 -//@[next] check-pass //@ compile-flags: -Zvalidate-mir //@ edition:2021 diff --git a/tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.rs b/tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.rs index 3ca4976b19195..774ea54e20895 100644 --- a/tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.rs +++ b/tests/ui/trivial-bounds/cant-normalize-fully-concrete-const.rs @@ -6,7 +6,7 @@ //@[old] known-bug: #135617 // The bound `for<'a> (): Project` prevents us from normalizing the -// array length. This caused and ICE with the new solver. The actual +// array length. This caused an ICE with the new solver. The actual // behavior doesn't really matter here as long as it doesn't ICE. trait Project {