]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/span/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.
11 fn id
<T
>(x
: T
) -> T { x }
14 let old
= ['o'
]; // statement 0
15 let mut v1
= Vec
::new(); // statement 1
17 let mut v2
= Vec
::new(); // statement 2
19 let young
= ['y'
]; // statement 3
21 v2
.push(&young
[0]); // statement 4
22 //~^ ERROR `young[..]` does not live long enough
23 //~| NOTE borrowed value does not live long enough
24 //~| NOTE values in a scope are dropped in the opposite order they are created
26 let mut v3
= Vec
::new(); // statement 5
28 v3
.push(&id('x'
)); // statement 6
29 //~^ ERROR borrowed value does not live long enough
30 //~| NOTE temporary value does not live long enough
31 //~| NOTE temporary value dropped here while still borrowed
32 //~| NOTE consider using a `let` binding to increase its lifetime
36 let mut v4
= Vec
::new(); // (sub) statement 0
39 //~^ ERROR borrowed value does not live long enough
40 //~| NOTE temporary value does not live long enough
41 //~| NOTE temporary value dropped here while still borrowed
42 //~| NOTE consider using a `let` binding to increase its lifetime
45 //~^ NOTE temporary value needs to live until here
47 let mut v5
= Vec
::new(); // statement 8
50 //~^ ERROR borrowed value does not live long enough
51 //~| NOTE temporary value does not live long enough
52 //~| NOTE temporary value dropped here while still borrowed
53 //~| NOTE consider using a `let` binding to increase its lifetime
57 //~^ NOTE `young[..]` dropped here while still borrowed
58 //~| NOTE temporary value needs to live until here
59 //~| NOTE temporary value needs to live until here