]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs
Move parse-fail tests to UI
[rust.git] / src / test / ui / lint / issue-47775-nested-macro-unnecessary-parens-arg.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // compile-pass
12
13 #![warn(unused_parens)]
14
15 macro_rules! the_worship_the_heart_lifts_above {
16     ( @as_expr, $e:expr) => { $e };
17     ( @generate_fn, $name:tt) => {
18         #[allow(dead_code)] fn the_moth_for_the_star<'a>() -> Option<&'a str> {
19             Some(the_worship_the_heart_lifts_above!( @as_expr, $name ))
20         }
21     };
22     ( $name:ident ) => { the_worship_the_heart_lifts_above!( @generate_fn, (stringify!($name))); }
23     // ↑ Notably, this does 𝘯𝘰𝘵 warn: we're declining to lint unused parens in
24     // function/method arguments inside of nested macros because of situations
25     // like those reported in Issue #47775
26 }
27
28 macro_rules! and_the_heavens_reject_not {
29     () => {
30         // ↓ But let's test that we still lint for unused parens around
31         // function args inside of simple, one-deep macros.
32         #[allow(dead_code)] fn the_night_for_the_morrow() -> Option<isize> { Some((2)) }
33         //~^ WARN unnecessary parentheses around function argument
34     }
35 }
36
37 the_worship_the_heart_lifts_above!(rah);
38 and_the_heavens_reject_not!();
39
40 fn main() {}