Closed
Description
Assigning to a mutable vector causes it to be modified in-place even if the right side of the assignment references it.
#[test]
fn mutable_vector_in_place_assignment () {
let mut t = [1u, ..2];
t = [t[1] * 2, t[0] * 2];
assert_eq!(t.as_slice(), &[2, 2]);
}
running 1 test
test mutable_vector_in_place_assignment ... FAILED
failures:
---- mutable_vector_in_place_assignment stdout ----
task 'mutable_vector_in_place_assignment' failed at 'assertion failed: `(left == right) && (right == left)` (left: `[2, 4]`, right: `[2, 2]`)', test2.rs:5
failures:
mutable_vector_in_place_assignment
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
task '<main>' failed at 'Some tests failed', /build/rust-git/src/rust/src/libtest/lib.rs:242
On IRC, @Kimundi pointed me to #15300, which might be related.