2012-04-05 22:59:36 -05:00
|
|
|
// The type of `y` ends up getting inferred to the type of the block.
|
2013-01-17 18:30:59 -06:00
|
|
|
fn broken() {
|
2015-01-31 10:23:42 -06:00
|
|
|
let mut x = 3;
|
2016-10-29 16:54:04 -05:00
|
|
|
let mut _y = vec![&mut x];
|
2014-06-13 22:48:09 -05:00
|
|
|
while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed
|
|
|
|
let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
|
2017-12-10 14:29:24 -06:00
|
|
|
_y.push(&mut z);
|
2017-12-14 11:57:34 -06:00
|
|
|
//~^ ERROR `z` does not live long enough
|
2019-04-22 02:40:08 -05:00
|
|
|
x += 1; //~ ERROR cannot use `x` because it was mutably borrowed
|
2017-12-10 14:29:24 -06:00
|
|
|
}
|
2012-04-05 22:59:36 -05:00
|
|
|
}
|
|
|
|
|
2013-01-17 18:30:59 -06:00
|
|
|
fn main() { }
|