From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/impl-trait/bound-normalization-fail.rs | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/test/ui/impl-trait/bound-normalization-fail.rs (limited to 'src/test/ui/impl-trait/bound-normalization-fail.rs') diff --git a/src/test/ui/impl-trait/bound-normalization-fail.rs b/src/test/ui/impl-trait/bound-normalization-fail.rs new file mode 100644 index 000000000..332959247 --- /dev/null +++ b/src/test/ui/impl-trait/bound-normalization-fail.rs @@ -0,0 +1,48 @@ +// edition:2018 + +// See issue 60414 + +// Reduction to `impl Trait` + +struct Foo(T); + +trait FooLike { + type Output; +} + +impl FooLike for Foo { + type Output = T; +} + +mod impl_trait { + use super::*; + + trait Trait { + type Assoc; + } + + /// `T::Assoc` can't be normalized any further here. + fn foo_fail() -> impl FooLike { + //~^ ERROR: type mismatch + Foo(()) + } +} + +// Same with lifetimes in the trait + +mod lifetimes { + use super::*; + + trait Trait<'a> { + type Assoc; + } + + /// Missing bound constraining `Assoc`, `T::Assoc` can't be normalized further. + fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike { + //~^ ERROR `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope + //~| ERROR: type mismatch + Foo(()) + } +} + +fn main() {} -- cgit v1.2.3