Graydon Hoare | d1affff | 2012-12-11 01:32:48 | [diff] [blame] | 1 | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT |
| 2 | // file at the top-level directory of this distribution and at |
| 3 | // http://rust-lang.org/COPYRIGHT. |
| 4 | // |
| 5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | // option. This file may not be copied, modified, or distributed |
| 9 | // except according to those terms. |
| 10 | |
Niko Matsakis | 5e54a73 | 2013-10-29 10:14:59 | [diff] [blame] | 11 | // Check that taking the address of an argument yields a lifetime |
| 12 | // bounded by the current function call. |
| 13 | |
Huon Wilson | 0c70ce1 | 2015-01-08 10:54:35 | [diff] [blame^] | 14 | fn foo(a: isize) { |
| 15 | let _p: &'static isize = &a; //~ ERROR `a` does not live long enough |
Niko Matsakis | 28d0ce9 | 2012-05-19 17:31:48 | [diff] [blame] | 16 | } |
| 17 | |
Huon Wilson | 0c70ce1 | 2015-01-08 10:54:35 | [diff] [blame^] | 18 | fn bar(a: isize) { |
| 19 | let _q: &isize = &a; |
Niko Matsakis | 5e54a73 | 2013-10-29 10:14:59 | [diff] [blame] | 20 | } |
| 21 | |
Huon Wilson | 0c70ce1 | 2015-01-08 10:54:35 | [diff] [blame^] | 22 | fn zed<'a>(a: isize) -> &'a isize { |
Niko Matsakis | 3805c54 | 2014-02-10 12:44:03 | [diff] [blame] | 23 | &a //~ ERROR `a` does not live long enough |
Niko Matsakis | 28d0ce9 | 2012-05-19 17:31:48 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | fn main() { |
Patrick Walton | 9143688 | 2013-02-14 19:47:00 | [diff] [blame] | 27 | } |