]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-free-region-ordering-caller.rs
Rollup merge of #70038 - DutchGhost:const-forget-tests, r=RalfJung
[rust.git] / src / test / 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 // revisions: migrate nll
6 //[nll]compile-flags: -Z borrowck=mir
7
8 struct Paramd<'a> { x: &'a usize }
9
10 fn call2<'a, 'b>(a: &'a usize, b: &'b usize) {
11     let z: Option<&'b &'a usize> = None;//[migrate]~ ERROR E0491
12     //[nll]~^ ERROR lifetime may not live long enough
13 }
14
15 fn call3<'a, 'b>(a: &'a usize, b: &'b usize) {
16     let y: Paramd<'a> = Paramd { x: a };
17     let z: Option<&'b Paramd<'a>> = None;//[migrate]~ ERROR E0491
18     //[nll]~^ ERROR lifetime may not live long enough
19 }
20
21 fn call4<'a, 'b>(a: &'a usize, b: &'b usize) {
22     let z: Option<&'a &'b usize> = None;//[migrate]~ ERROR E0491
23     //[nll]~^ ERROR lifetime may not live long enough
24 }
25
26 fn main() {}