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