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