Closed
Description
This USED to be an error, but doesn't seem to be anymore:
use core::either::{Either, Left, Right};
fn f(x: &mut Either<int,float>, y: &Either<int,float>) -> int {
match *y {
Left(ref z) => {
*x = Right(1.0);
*z
}
_ => fail
}
}
fn main() {
let mut x: Either<int,float> = Left(3);
io::println(f(&mut x, &x).to_str());
}
In particular it should not be allowed to simultaneously have an &mut and an & in scope. I recall that I changed the rules at some point around the creation of &mut pointers—that used to be considered equivalent to writing to the variable in question. I should not have changed that rule!