]> git.proxmox.com Git - rustc.git/blame - src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / regions / regions-implied-bounds-projection-gap-1.rs
CommitLineData
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
6trait Trait1<'x> {
7 type Foo;
8}
9
10// calling this fn should trigger a check that the type argument
11// supplied is well-formed.
12fn wf<T>() { }
13
14fn 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
20fn caller2<'x, T:Trait1<'x>>(t: &'x T)
21{
22 wf::<&'x T::Foo>(); // OK
23}
24
25fn caller3<'x, T:Trait1<'x>>(t: &'x T::Foo)
26{
27 wf::<&'x T::Foo>(); // OK
28}
29
30fn main() { }