]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs
Rollup merge of #66128 - emilio:new-zeroed, r=SimonSapin
[rust.git] / src / test / ui / lint / issue-47775-nested-macro-unnecessary-parens-arg.rs
1 // check-pass
2
3 #![warn(unused_parens)]
4
5 macro_rules! the_worship_the_heart_lifts_above {
6     ( @as_expr, $e:expr) => { $e };
7     ( @generate_fn, $name:tt) => {
8         #[allow(dead_code)] fn the_moth_for_the_star<'a>() -> Option<&'a str> {
9             Some(the_worship_the_heart_lifts_above!( @as_expr, $name ))
10         }
11     };
12     ( $name:ident ) => { the_worship_the_heart_lifts_above!( @generate_fn, (stringify!($name))); }
13     // ↑ Notably, this does 𝘯𝘰𝘵 warn: we're declining to lint unused parens in
14     // function/method arguments inside of nested macros because of situations
15     // like those reported in Issue #47775
16 }
17
18 macro_rules! and_the_heavens_reject_not {
19     () => {
20         // ↓ But let's test that we still lint for unused parens around
21         // function args inside of simple, one-deep macros.
22         #[allow(dead_code)] fn the_night_for_the_morrow() -> Option<isize> { Some((2)) }
23         //~^ WARN unnecessary parentheses around function argument
24     }
25 }
26
27 the_worship_the_heart_lifts_above!(rah);
28 and_the_heavens_reject_not!();
29
30 fn main() {}