diff --git a/tests/ui/associated-types/normalize-supertrait-projection-in-dyn-61083.rs b/tests/ui/associated-types/normalize-supertrait-projection-in-dyn-61083.rs new file mode 100644 index 0000000000000..fb93a97328bf4 --- /dev/null +++ b/tests/ui/associated-types/normalize-supertrait-projection-in-dyn-61083.rs @@ -0,0 +1,28 @@ +//! Regression test for . +//! +//! An associated type projection in a supertrait bound (`Bar: Foo`) +//! failed to normalize when the `Bar` bound was reached through a trait object, +//! so passing the object to a function expecting `Foo` was rejected. + +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@ check-pass + +trait Foo {} + +trait Bar: Foo {} + +fn a(_x: &(impl Foo + ?Sized)) {} + +// The `dyn` form is the one that used to fail to normalize `T::Item` to `u32`. +fn b(y: &dyn Bar>) { + a(y) +} + +// The equivalent `impl Trait` form always compiled; keep it so both paths stay pinned. +fn c(y: &(impl Bar> + ?Sized)) { + a(y) +} + +fn main() {}