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.
The following code fails to compile:
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.