]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 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 | ||
9346a6ac | 11 | trait ListItem<'a> { |
1a4d82fc JJ |
12 | fn list_name() -> &'a str; |
13 | } | |
14 | ||
15 | trait Collection { fn len(&self) -> usize; } | |
16 | ||
0bf4aa26 | 17 | // is now well formed. RFC 2093 |
1a4d82fc | 18 | struct List<'a, T: ListItem<'a>> { |
e9174d1e | 19 | slice: &'a [T] |
1a4d82fc | 20 | } |
ea8adc8c | 21 | |
1a4d82fc JJ |
22 | impl<'a, T: ListItem<'a>> Collection for List<'a, T> { |
23 | fn len(&self) -> usize { | |
24 | 0 | |
25 | } | |
26 | } | |
27 | ||
ea8adc8c XL |
28 | struct Foo<T> { |
29 | foo: &'static T | |
ff7c6d11 | 30 | //~^ ERROR may not live long enough |
ea8adc8c XL |
31 | } |
32 | ||
33 | trait X<K>: Sized { | |
34 | fn foo<'a, L: X<&'a Nested<K>>>(); | |
ff7c6d11 XL |
35 | //~^ ERROR may not live long enough |
36 | ||
ea8adc8c XL |
37 | // check that we give a sane error for `Self` |
38 | fn bar<'a, L: X<&'a Nested<Self>>>(); | |
ff7c6d11 XL |
39 | //~^ ERROR may not live long enough |
40 | ||
41 | // check that we give a sane error for nested generics | |
42 | fn baz<'a, L, M: X<&'a Nested<L>>>() { | |
43 | //~^ ERROR may not live long enough | |
44 | } | |
ea8adc8c XL |
45 | } |
46 | ||
ff7c6d11 XL |
47 | trait TraitB {} |
48 | ||
ea8adc8c XL |
49 | struct Nested<K>(K); |
50 | impl<K> Nested<K> { | |
51 | fn generic_in_parent<'a, L: X<&'a Nested<K>>>() { | |
ff7c6d11 | 52 | //~^ ERROR may not live long enough |
ea8adc8c XL |
53 | } |
54 | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() { | |
ff7c6d11 | 55 | //~^ ERROR may not live long enough |
ea8adc8c XL |
56 | } |
57 | } | |
58 | ||
1a4d82fc | 59 | fn main() {} |