]>
Commit | Line | Data |
---|---|---|
416331ca XL |
1 | // edition:2018 |
2 | ||
416331ca XL |
3 | // See issue 60414 |
4 | ||
416331ca XL |
5 | // Reduction to `impl Trait` |
6 | ||
7 | struct Foo<T>(T); | |
8 | ||
136023e0 XL |
9 | trait FooLike { |
10 | type Output; | |
11 | } | |
416331ca XL |
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. | |
136023e0 | 25 | fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> { |
416331ca XL |
26 | //~^ ERROR: type mismatch |
27 | Foo(()) | |
28 | } | |
29 | } | |
30 | ||
416331ca XL |
31 | // Same with lifetimes in the trait |
32 | ||
33 | mod lifetimes { | |
34 | use super::*; | |
35 | ||
36 | trait Trait<'a> { | |
37 | type Assoc; | |
38 | } | |
39 | ||
40 | /// Missing bound constraining `Assoc`, `T::Assoc` can't be normalized further. | |
136023e0 | 41 | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { |
ee023bcb FG |
42 | //~^ ERROR `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope |
43 | //~| ERROR: type mismatch | |
416331ca XL |
44 | Foo(()) |
45 | } | |
46 | } | |
47 | ||
48 | fn main() {} |