Closed
Description
In the following reduced code the call to do_bad_thing
invalidates the iterator in main
.
fn do_bad_thing(grid: &mut Vec<Vec<u8>>) {
grid[0] = vec![];
}
fn main() {
let mut v: Vec<Vec<u8>> = vec![vec![1,2,3,4,5]];
for i in v[0].iter() {
println!("i = {}", i);
do_bad_thing(&mut v);
}
}
Running this locally produces (without optimizations):
i = 1
i = 2
i = 32
i = 0
i = 61
On playpen this does not give wrong results, but it does compile (which is the actual problem).
I'm running rustc on Windows:
rustc --version
rustc 0.13.0-nightly (7e11b2271 2014-12-24 20:47:12 +0000)
Metadata
Metadata
Assignees
Labels
No labels