]>
Commit | Line | Data |
---|---|---|
dc9dc135 XL |
1 | // edition:2018 |
2 | ||
dc9dc135 XL |
3 | trait Trait<'a, 'b> {} |
4 | impl<T> Trait<'_, '_> for T {} | |
5 | ||
6 | // `Ordinary<'a> <: Ordinary<'b>` if `'a: 'b`, as with most types. | |
7 | // | |
8 | // I am purposefully avoiding the terms co- and contra-variant because | |
9 | // their application to regions depends on how you interpreted Rust | |
10 | // regions. -nikomatsakis | |
11 | struct Ordinary<'a>(&'a u8); | |
12 | ||
13 | // Here we get an error because none of our choices (either `'d` nor `'e`) are outlived | |
14 | // by both `'a` and `'b`. | |
15 | ||
16 | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e> | |
dc9dc135 XL |
17 | where |
18 | 'a: 'e, | |
19 | 'b: 'd, | |
20 | { | |
21 | // Hidden type `Ordinary<'0>` with constraints: | |
22 | // | |
23 | // ``` | |
24 | // 'a: '0 | |
25 | // 'b: '0 | |
26 | // 'a in ['d, 'e] | |
27 | // ``` | |
28 | if condition() { a } else { b } | |
ee023bcb | 29 | //~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds |
dc9dc135 XL |
30 | } |
31 | ||
32 | fn condition() -> bool { | |
33 | true | |
34 | } | |
35 | ||
36 | fn main() {} |