2013-04-01 22:32:37 -07:00
|
|
|
// Test various ways to construct a pointer with a longer lifetime
|
|
|
|
// than the thing it points at and ensure that they result in
|
|
|
|
// errors. See also regions-free-region-ordering-callee.rs
|
|
|
|
|
2015-01-08 22:02:42 +11:00
|
|
|
struct Paramd<'a> { x: &'a usize }
|
2013-04-01 22:32:37 -07:00
|
|
|
|
2015-01-08 22:02:42 +11:00
|
|
|
fn call2<'a, 'b>(a: &'a usize, b: &'b usize) {
|
2022-04-01 13:13:25 -04:00
|
|
|
let z: Option<&'b &'a usize> = None;
|
|
|
|
//~^ ERROR lifetime may not live long enough
|
2013-04-01 22:32:37 -07:00
|
|
|
}
|
|
|
|
|
2015-01-08 22:02:42 +11:00
|
|
|
fn call3<'a, 'b>(a: &'a usize, b: &'b usize) {
|
2013-04-01 22:32:37 -07:00
|
|
|
let y: Paramd<'a> = Paramd { x: a };
|
2022-04-01 13:13:25 -04:00
|
|
|
let z: Option<&'b Paramd<'a>> = None;
|
|
|
|
//~^ ERROR lifetime may not live long enough
|
2013-04-01 22:32:37 -07:00
|
|
|
}
|
|
|
|
|
2015-01-08 22:02:42 +11:00
|
|
|
fn call4<'a, 'b>(a: &'a usize, b: &'b usize) {
|
2022-04-01 13:13:25 -04:00
|
|
|
let z: Option<&'a &'b usize> = None;
|
|
|
|
//~^ ERROR lifetime may not live long enough
|
2013-04-01 22:32:37 -07:00
|
|
|
}
|
|
|
|
|
2013-09-23 17:20:36 -07:00
|
|
|
fn main() {}
|