]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/borrowck/borrowck-let-suggestion-suffixes.rs
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
17 let young
= ['y'
]; // statement 3
19 v2
.push(&young
[0]); // statement 4
20 //~^ ERROR `young[..]` does not live long enough
21 //~| NOTE does not live long enough
22 //~| NOTE values in a scope are dropped in the opposite order they are created
24 let mut v3
= Vec
::new(); // statement 5
26 v3
.push(&'x'
); // statement 6
27 //~^ ERROR borrowed value does not live long enough
28 //~| NOTE temporary value created here
29 //~| NOTE temporary value only lives until here
30 //~| NOTE consider using a `let` binding to increase its lifetime
34 let mut v4
= Vec
::new(); // (sub) statement 0
37 //~^ ERROR borrowed value does not live long enough
38 //~| NOTE temporary value created here
39 //~| NOTE temporary value only lives until here
40 //~| NOTE consider using a `let` binding to increase its lifetime
43 //~^ NOTE temporary value needs to live until here
45 let mut v5
= Vec
::new(); // statement 8
48 //~^ ERROR borrowed value does not live long enough
49 //~| NOTE temporary value created here
50 //~| NOTE temporary value only lives until here
51 //~| NOTE consider using a `let` binding to increase its lifetime
55 //~^ NOTE borrowed value dropped before borrower
56 //~| NOTE temporary value needs to live until here
57 //~| NOTE temporary value needs to live until here