1 fn id<T>(x: T) -> T { x }
4 let old = ['o']; // statement 0
5 let mut v1 = Vec::new(); // statement 1
7 let mut v2 = Vec::new(); // statement 2
10 let young = ['y']; // statement 3
11 //~^ NOTE binding `young` declared here
13 v2.push(&young[0]); // statement 4
14 //~^ ERROR `young[_]` does not live long enough
15 //~| NOTE borrowed value does not live long enough
16 } //~ NOTE `young[_]` dropped here while still borrowed
18 let mut v3 = Vec::new(); // statement 5
20 v3.push(&id('x')); // statement 6
21 //~^ ERROR temporary value dropped while borrowed
22 //~| NOTE creates a temporary value which is freed while still in use
23 //~| NOTE temporary value is freed at the end of this statement
24 //~| HELP consider using a `let` binding to create a longer lived value
28 let mut v4 = Vec::new(); // (sub) statement 0
31 //~^ ERROR temporary value dropped while borrowed
32 //~| NOTE creates a temporary value which is freed while still in use
33 //~| NOTE temporary value is freed at the end of this statement
34 //~| NOTE consider using a `let` binding to create a longer lived value
36 //~^ NOTE borrow later used here
39 let mut v5 = Vec::new(); // statement 8
42 //~^ ERROR temporary value dropped while borrowed
43 //~| NOTE creates a temporary value which is freed while still in use
44 //~| NOTE temporary value is freed at the end of this statement
45 //~| HELP consider using a `let` binding to create a longer lived value
49 (v1, v2, v3, /* v4 is above. */ v5).use_ref();
50 //~^ NOTE borrow later used here
51 //~| NOTE borrow later used here
52 //~| NOTE borrow later used here
59 trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
60 impl<T> Fake for T { }