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