]> git.lizzy.rs Git - rust.git/blob - tests/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original-type-alias-impl-trait.rs
Rollup merge of #106661 - mjguzik:linux_statx, r=Mark-Simulacrum
[rust.git] / tests / ui / impl-trait / multiple-lifetimes / ordinary-bounds-pick-original-type-alias-impl-trait.rs
1 // edition:2018
2 // check-pass
3
4 #![feature(type_alias_impl_trait)]
5 trait Trait<'a, 'b> {}
6 impl<T> Trait<'_, '_> for T {}
7
8 // Here we wind up selecting `'a` and `'b` in the hidden type because
9 // those are the types that appear in the original values.
10
11 type Foo<'a, 'b> = impl Trait<'a, 'b>;
12
13 fn upper_bounds<'a, 'b>(a: &'a u8, b: &'b u8) -> Foo<'a, 'b> {
14     // In this simple case, you have a hidden type `(&'0 u8, &'1 u8)` and constraints like
15     //
16     // ```
17     // 'a: '0
18     // 'b: '1
19     // '0 in ['a, 'b]
20     // '1 in ['a, 'b]
21     // ```
22     //
23     // We use the fact that `'a: 0'` must hold (combined with the in
24     // constraint) to determine that `'0 = 'a` must be the answer.
25     (a, b)
26 }
27
28 fn main() {}