-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
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.A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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 code fails to compile:
#![deny(unused_parens)]
macro_rules! add1_block {
($e:expr) => {
{ let val = 1; $e + val }
}
}
macro_rules! add1_paren_block {
($e:expr) => {
({ let val = 1; $e + val })
}
}
fn main() {
let w = add1_block!(2);
let x = { add1_block!(3) as u64 };
let y = add1_paren_block!(4);
let z = { add1_paren_block!(5) as u64 };
println!("w: {} x: {} y: {} z: {}", w, x, y, z);
}
The parentheses in the macro are, in general, not unnecessary (for the explanation of why they are necessary, see #22450).
In general, it is silly for lint to be trying to fix style errors of this sort within macros. The place for such stylistic judgement, IMO, is within the original source code, not within macros.
Metadata
Metadata
Assignees
Labels
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.A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.