]>
git.proxmox.com Git - rustc.git/blob - 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
5 // revisions: migrate nll
6 //[nll]compile-flags: -Z borrowck=mir
8 struct Paramd
<'a
> { x: &'a usize }
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
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
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