]> git.proxmox.com Git - rustc.git/blame - src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / src / test / ui / impl-trait / multiple-lifetimes / ordinary-bounds-unrelated.rs
CommitLineData
dc9dc135
XL
1// edition:2018
2
dc9dc135
XL
3trait Trait<'a, 'b> {}
4impl<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
11struct 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
16fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e>
dc9dc135
XL
17where
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
32fn condition() -> bool {
33 true
34}
35
36fn main() {}