]> git.proxmox.com Git - rustc.git/blob - src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs
New upstream version 1.62.1+dfsg1
[rustc.git] / src / test / ui / regions / regions-implied-bounds-projection-gap-1.rs
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 // revisions: base nll
7 // ignore-compare-mode-nll
8 //[nll] compile-flags: -Z borrowck=mir
9
10 trait Trait1<'x> {
11 type Foo;
12 }
13
14 // calling this fn should trigger a check that the type argument
15 // supplied is well-formed.
16 fn wf<T>() { }
17
18 fn func<'x, T:Trait1<'x>>(t: &'x T::Foo)
19 {
20 wf::<&'x T>();
21 //~^ ERROR the parameter type `T` may not live long enough
22 }
23
24 fn caller2<'x, T:Trait1<'x>>(t: &'x T)
25 {
26 wf::<&'x T::Foo>(); // OK
27 }
28
29 fn caller3<'x, T:Trait1<'x>>(t: &'x T::Foo)
30 {
31 wf::<&'x T::Foo>(); // OK
32 }
33
34 fn main() { }