2013-10-29 06:14:59 -04:00
|
|
|
// Check that taking the address of an argument yields a lifetime
|
|
|
|
// bounded by the current function call.
|
|
|
|
|
2015-01-08 21:54:35 +11:00
|
|
|
fn foo(a: isize) {
|
|
|
|
let _p: &'static isize = &a; //~ ERROR `a` does not live long enough
|
2012-05-19 10:31:48 -07:00
|
|
|
}
|
|
|
|
|
2015-01-08 21:54:35 +11:00
|
|
|
fn bar(a: isize) {
|
|
|
|
let _q: &isize = &a;
|
2013-10-29 06:14:59 -04:00
|
|
|
}
|
|
|
|
|
2015-01-08 21:54:35 +11:00
|
|
|
fn zed<'a>(a: isize) -> &'a isize {
|
2019-04-22 08:40:08 +01:00
|
|
|
&a //~ ERROR cannot return reference to function parameter `a`
|
2012-05-19 10:31:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2013-02-14 11:47:00 -08:00
|
|
|
}
|