]> git.lizzy.rs Git - rust.git/blob - tests/ui/regions/regions-free-region-ordering-caller.rs
internally change regions to be covariant
[rust.git] / tests / ui / regions / regions-free-region-ordering-caller.rs
1 // Test various ways to construct a pointer with a longer lifetime
2 // than the thing it points at and ensure that they result in
3 // errors. See also regions-free-region-ordering-callee.rs
4
5 struct Paramd<'a> { x: &'a usize }
6
7 fn call2<'a, 'b>(a: &'a usize, b: &'b usize) {
8     let z: Option<&'b &'a usize> = None;
9     //~^ ERROR lifetime may not live long enough
10 }
11
12 fn call3<'a, 'b>(a: &'a usize, b: &'b usize) {
13     let y: Paramd<'a> = Paramd { x: a };
14     let z: Option<&'b Paramd<'a>> = None;
15     //~^ ERROR lifetime may not live long enough
16 }
17
18 fn call4<'a, 'b>(a: &'a usize, b: &'b usize) {
19     let z: Option<&'a &'b usize> = None;
20     //~^ ERROR lifetime may not live long enough
21 }
22
23 fn main() {}