]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs
Rollup merge of #53317 - estebank:abolish-ice, r=oli-obk
[rust.git] / src / test / ui / regions / regions-implied-bounds-projection-gap-1.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-compare-mode-nll
12
13 // Illustrates the "projection gap": in this test, even though we know
14 // that `T::Foo: 'x`, that does not tell us that `T: 'x`, because
15 // there might be other ways for the caller of `func` to show that
16 // `T::Foo: 'x` holds (e.g., where-clause).
17
18 trait Trait1<'x> {
19     type Foo;
20 }
21
22 // calling this fn should trigger a check that the type argument
23 // supplied is well-formed.
24 fn wf<T>() { }
25
26 fn func<'x, T:Trait1<'x>>(t: &'x T::Foo)
27 {
28     wf::<&'x T>();
29     //~^ ERROR the parameter type `T` may not live long enough
30 }
31
32 fn caller2<'x, T:Trait1<'x>>(t: &'x T)
33 {
34     wf::<&'x T::Foo>(); // OK
35 }
36
37 fn caller3<'x, T:Trait1<'x>>(t: &'x T::Foo)
38 {
39     wf::<&'x T::Foo>(); // OK
40 }
41
42 fn main() { }