blob: c54b4aaace5fb10d61bb8d112d7425e3dcdfe109 [file] [log] [blame]
Graydon Hoared1affff2012-12-11 01:32:481// 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 Matsakis5e54a732013-10-29 10:14:5911// Check that taking the address of an argument yields a lifetime
12// bounded by the current function call.
13
Huon Wilson0c70ce12015-01-08 10:54:3514fn foo(a: isize) {
15 let _p: &'static isize = &a; //~ ERROR `a` does not live long enough
Niko Matsakis28d0ce92012-05-19 17:31:4816}
17
Huon Wilson0c70ce12015-01-08 10:54:3518fn bar(a: isize) {
19 let _q: &isize = &a;
Niko Matsakis5e54a732013-10-29 10:14:5920}
21
Huon Wilson0c70ce12015-01-08 10:54:3522fn zed<'a>(a: isize) -> &'a isize {
Niko Matsakis3805c542014-02-10 12:44:0323 &a //~ ERROR `a` does not live long enough
Niko Matsakis28d0ce92012-05-19 17:31:4824}
25
26fn main() {
Patrick Walton91436882013-02-14 19:47:0027}