1 // Copyright 2015 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.
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.
12 let old = ['o']; // statement 0
13 let mut v1 = Vec::new(); // statement 1
15 let mut v2 = Vec::new(); // statement 2
16 //~^ NOTE reference must be valid for the block suffix following statement 2
18 let young = ['y']; // statement 3
19 //~^ NOTE ...but borrowed value is only valid for the block suffix following statement 3
21 v2.push(&young[0]); // statement 4
22 //~^ ERROR `young[..]` does not live long enough
24 let mut v3 = Vec::new(); // statement 5
25 //~^ NOTE reference must be valid for the block suffix following statement 5
27 v3.push(&'x'); // statement 6
28 //~^ ERROR borrowed value does not live long enough
29 //~| does not live long enough
30 //~| NOTE ...but borrowed value is only valid for the statement
31 //~| HELP consider using a `let` binding to increase its lifetime
35 let mut v4 = Vec::new(); // (sub) statement 0
36 //~^ NOTE reference must be valid for the block suffix following statement 0
39 //~^ ERROR borrowed value does not live long enough
40 //~| does not live long enough
41 //~| NOTE ...but borrowed value is only valid for the statement
42 //~| HELP consider using a `let` binding to increase its lifetime
46 let mut v5 = Vec::new(); // statement 8
47 //~^ NOTE reference must be valid for the block suffix following statement 8
50 //~^ ERROR borrowed value does not live long enough
51 //~| does not live long enough
52 //~| NOTE ...but borrowed value is only valid for the statement
53 //~| HELP consider using a `let` binding to increase its lifetime