From 1253a875d17e122dc181a6a7842182bf12875deb Mon Sep 17 00:00:00 2001 From: malezjaa Date: Sat, 29 Aug 2026 23:32:51 +0200 Subject: [PATCH] regression test for unexpected region ICE --- .../assoc-const-equality-unexpected-region.rs | 14 +++++++ ...oc-const-equality-unexpected-region.stderr | 40 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/ui/associated-consts/assoc-const-equality-unexpected-region.rs create mode 100644 tests/ui/associated-consts/assoc-const-equality-unexpected-region.stderr diff --git a/tests/ui/associated-consts/assoc-const-equality-unexpected-region.rs b/tests/ui/associated-consts/assoc-const-equality-unexpected-region.rs new file mode 100644 index 0000000000000..e8a3dcf47eea3 --- /dev/null +++ b/tests/ui/associated-consts/assoc-const-equality-unexpected-region.rs @@ -0,0 +1,14 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/143896. + +trait TraitA<'a> { + const K: usize = 0; +} + +impl TraitA<'_> for () {} +//~^ ERROR the type parameter `T` is not constrained + +impl dyn TraitA<'_> where (): TraitA<'a, K = 0> {} +//~^ ERROR use of undeclared lifetime name `'a` +//~| ERROR associated const equality is incomplete + +pub fn main() {} diff --git a/tests/ui/associated-consts/assoc-const-equality-unexpected-region.stderr b/tests/ui/associated-consts/assoc-const-equality-unexpected-region.stderr new file mode 100644 index 0000000000000..6e38e3e41acbf --- /dev/null +++ b/tests/ui/associated-consts/assoc-const-equality-unexpected-region.stderr @@ -0,0 +1,40 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/assoc-const-equality-unexpected-region.rs:10:38 + | +LL | impl dyn TraitA<'_> where (): TraitA<'a, K = 0> {} + | ^^ undeclared lifetime + | + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | impl dyn TraitA<'_> where (): for<'a> TraitA<'a, K = 0> {} + | +++++++ +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | impl dyn TraitA<'_> where for<'a> (): TraitA<'a, K = 0> {} + | +++++++ +help: consider introducing lifetime `'a` here + | +LL | impl<'a> dyn TraitA<'_> where (): TraitA<'a, K = 0> {} + | ++++ + +error[E0658]: associated const equality is incomplete + --> $DIR/assoc-const-equality-unexpected-region.rs:10:42 + | +LL | impl dyn TraitA<'_> where (): TraitA<'a, K = 0> {} + | ^^^^^ + | + = note: see issue #132980 for more information + = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates + --> $DIR/assoc-const-equality-unexpected-region.rs:7:6 + | +LL | impl TraitA<'_> for () {} + | ^ unconstrained type parameter + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0207, E0261, E0658. +For more information about an error, try `rustc --explain E0207`.