Closed
Description
When trying to compile
fn main() {
let mut buf = &[1, 2, 3, 4];
let mut dst = &[0, 0, 0, 0];
for (x, y) in buf.iter_mut().zip(dst) {
*y = *x
}
}
the compiler rustc 1.17.0-nightly (3da4023 2017-03-24) throws an error together with a helpful suggestion
error: cannot borrow immutable borrowed content `*buf` as mutable
--> <anon>:4:19
|
2 | let mut buf = &[1, 2, 3, 4];
| ------- consider changing this to `mut mut buf`
3 | let mut dst = &[0, 0, 0, 0];
4 | for (x, y) in buf.iter_mut().zip(dst) {
| ^^^ cannot borrow as mutable
Here, the mut mut buf
is obviously very very wrong. The stable and beta compilers don't suffer from this issue (they just provide no „consider …“ message at all).