Open
Description
The following gives a suggestion to remove the mut
which will cause the code to fail to compile.
macro_rules! array {
($($element:expr),*) => {{
let mut array = Vec::new();
$(
array.push($element);
)*
array
}};
}
fn main() {
let _x: Vec<i32> = array![];
let _y: Vec<i32> = array![1,2,3];
}
warning: variable does not need to be mutable
--> src/main.rs:3:13
|
3 | let mut array = Vec::new();
| ----^^^^^
| |
| help: remove this `mut`
...
12 | let _x: Vec<i32> = array!{};
| -------- in this macro invocation
|
= note: #[warn(unused_mut)] on by default
This causes cargo fix
to fail.
(Sorry if this is a dupe, I went hunting but couldn't find any issues that were the same.)