]>
Commit | Line | Data |
---|---|---|
ff7c6d11 XL |
1 | // Test that regions which appear only in the closure's generics (in |
2 | // this case, `'a`) are properly mapped to the creator's generics. In | |
3 | // this case, the closure constrains its type parameter `T` to outlive | |
4 | // the same `'a` for which it implements `Trait`, which can only be the `'a` | |
5 | // from the function definition. | |
6 | ||
923072b8 | 7 | // compile-flags:-Zverbose |
ff7c6d11 XL |
8 | |
9 | #![feature(rustc_attrs)] | |
10 | #![allow(dead_code)] | |
11 | ||
12 | trait Trait<'a> {} | |
13 | ||
14 | fn establish_relationships<T, F>(value: T, closure: F) | |
15 | where | |
16 | F: FnOnce(T), | |
17 | { | |
18 | closure(value) | |
19 | } | |
20 | ||
21 | fn require<'a, T>(t: T) | |
22 | where | |
23 | T: Trait<'a> + 'a, | |
24 | { | |
25 | } | |
26 | ||
27 | #[rustc_regions] | |
28 | fn supply<'a, T>(value: T) | |
29 | where | |
30 | T: Trait<'a>, | |
31 | { | |
32 | establish_relationships(value, |value| { | |
33 | //~^ ERROR the parameter type `T` may not live long enough | |
34 | ||
35 | // This function call requires that | |
36 | // | |
37 | // (a) T: Trait<'a> | |
38 | // | |
39 | // and | |
40 | // | |
41 | // (b) T: 'a | |
42 | // | |
43 | // The latter does not hold. | |
44 | ||
45 | require(value); | |
ff7c6d11 XL |
46 | }); |
47 | } | |
48 | ||
49 | fn main() {} |