]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/bound-normalization-fail.rs
Rollup merge of #95504 - jyn514:library-alias, r=Mark-Simulacrum
[rust.git] / src / test / ui / impl-trait / bound-normalization-fail.rs
1 // edition:2018
2
3 // See issue 60414
4
5 // Reduction to `impl Trait`
6
7 struct Foo<T>(T);
8
9 trait FooLike {
10     type Output;
11 }
12
13 impl<T> FooLike for Foo<T> {
14     type Output = T;
15 }
16
17 mod impl_trait {
18     use super::*;
19
20     trait Trait {
21         type Assoc;
22     }
23
24     /// `T::Assoc` can't be normalized any further here.
25     fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> {
26         //~^ ERROR: type mismatch
27         //~| ERROR: type mismatch
28         Foo(())
29     }
30 }
31
32 // Same with lifetimes in the trait
33
34 mod lifetimes {
35     use super::*;
36
37     trait Trait<'a> {
38         type Assoc;
39     }
40
41     /// Missing bound constraining `Assoc`, `T::Assoc` can't be normalized further.
42     fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> {
43         //~^ ERROR `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
44         //~| ERROR: type mismatch
45         //~| ERROR: type mismatch
46         Foo(())
47     }
48 }
49
50 fn main() {}