The compiler doesn't notice and/or warn that a mutable reference in a match arm pattern doesn't need to be mutable.
I tried this code:
fn main() {
let mut option = Some(Box::new(0));
match option {
Some(ref mut v) => println!("{}", v),
None => (),
};
}
I expected to see this happen: The compiler would give a warning, saying that mut is unnecessary in the first match arm.
Instead, this happened: The compiler gives no warnings.
Meta
rustc --version --verbose:
rustc 1.27.0 (3eda71b00 2018-06-19)
binary: rustc
commit-hash: 3eda71b00ad48d7bf4eef4c443e7f611fd061418
commit-date: 2018-06-19
host: x86_64-apple-darwin
release: 1.27.0
LLVM version: 6.0
The compiler doesn't notice and/or warn that a mutable reference in a match arm pattern doesn't need to be mutable.
I tried this code:
I expected to see this happen: The compiler would give a warning, saying that
mutis unnecessary in the first match arm.Instead, this happened: The compiler gives no warnings.
Meta
rustc --version --verbose: