-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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.)
renatoathaydes and icecream17
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.