]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-free-region-ordering-callee.rs
Auto merge of #60093 - GuillaumeGomez:fix-attrs-pos, r=Manishearth
[rust.git] / src / test / ui / regions / regions-free-region-ordering-callee.rs
1 // Tests that callees correctly infer an ordering between free regions
2 // that appear in their parameter list.  See also
3 // regions-free-region-ordering-caller.rs
4
5 fn ordering1<'a, 'b>(x: &'a &'b usize) -> &'a usize {
6     // It is safe to assume that 'a <= 'b due to the type of x
7     let y: &'b usize = &**x;
8     return y;
9 }
10
11 fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize {
12     // However, it is not safe to assume that 'b <= 'a
13     &*y //~ ERROR lifetime mismatch [E0623]
14 }
15
16 fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize {
17     // Do not infer an ordering from the return value.
18     let z: &'b usize = &*x;
19     //~^ ERROR lifetime mismatch [E0623]
20     panic!();
21 }
22
23 // see regions-free-region-ordering-callee-4.rs
24
25 fn ordering5<'a, 'b>(a: &'a usize, b: &'b usize, x: Option<&'a &'b usize>) {
26     let z: Option<&'a &'b usize> = None;
27 }
28
29 fn main() {}