]>
Commit | Line | Data |
---|---|---|
e9174d1e SL |
1 | // Illustrates the "projection gap": in this test, even though we know |
2 | // that `T::Foo: 'x`, that does not tell us that `T: 'x`, because | |
3 | // there might be other ways for the caller of `func` to show that | |
4 | // `T::Foo: 'x` holds (e.g., where-clause). | |
5 | ||
6 | trait Trait1<'x> { | |
7 | type Foo; | |
8 | } | |
9 | ||
10 | // calling this fn should trigger a check that the type argument | |
11 | // supplied is well-formed. | |
12 | fn wf<T>() { } | |
13 | ||
14 | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) | |
15 | { | |
16 | wf::<&'x T>(); | |
17 | //~^ ERROR the parameter type `T` may not live long enough | |
18 | } | |
19 | ||
20 | fn caller2<'x, T:Trait1<'x>>(t: &'x T) | |
21 | { | |
22 | wf::<&'x T::Foo>(); // OK | |
23 | } | |
24 | ||
25 | fn caller3<'x, T:Trait1<'x>>(t: &'x T::Foo) | |
26 | { | |
27 | wf::<&'x T::Foo>(); // OK | |
28 | } | |
29 | ||
30 | fn main() { } |