]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs
Rollup merge of #105555 - krasimirgg:llvm-int-opt-2, r=cuviper
[rust.git] / src / test / ui / lifetimes / lifetime-doesnt-live-long-enough.rs
1 trait ListItem<'a> {
2     fn list_name() -> &'a str;
3 }
4
5 trait Collection { fn len(&self) -> usize; }
6
7 // is now well formed. RFC 2093
8 struct List<'a, T: ListItem<'a>> {
9     slice: &'a [T]
10 }
11
12 impl<'a, T: ListItem<'a>> Collection for List<'a, T> {
13     fn len(&self) -> usize {
14         0
15     }
16 }
17
18 struct Foo<T> {
19     foo: &'static T
20     //~^ ERROR may not live long enough
21 }
22
23 trait X<K>: Sized {
24     fn foo<'a, L: X<&'a Nested<K>>>();
25     //~^ ERROR may not live long enough
26
27     // check that we give a sane error for `Self`
28     fn bar<'a, L: X<&'a Nested<Self>>>();
29     //~^ ERROR may not live long enough
30
31     // check that we give a sane error for nested generics
32     fn baz<'a, L, M: X<&'a Nested<L>>>() {
33         //~^ ERROR may not live long enough
34     }
35 }
36
37 trait TraitB {}
38
39 struct Nested<K>(K);
40 impl<K> Nested<K> {
41     fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
42         //~^ ERROR may not live long enough
43     }
44     fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() {
45         //~^ ERROR may not live long enough
46     }
47 }
48
49 fn main() {}