]> git.proxmox.com Git - rustc.git/blob - src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.rs
New upstream version 1.54.0+dfsg1
[rustc.git] / src / test / ui / impl-trait / multiple-lifetimes / ordinary-bounds-unrelated.rs
1 // edition:2018
2
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>
17 //~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds
18 where
19 'a: 'e,
20 'b: 'd,
21 {
22 // Hidden type `Ordinary<'0>` with constraints:
23 //
24 // ```
25 // 'a: '0
26 // 'b: '0
27 // 'a in ['d, 'e]
28 // ```
29 if condition() { a } else { b }
30 }
31
32 fn condition() -> bool {
33 true
34 }
35
36 fn main() {}