]> git.lizzy.rs Git - rust.git/blob - tests/ui/proc-macro/capture-macro-rules-invoke.rs
Rollup merge of #106788 - estebank:elaborate_pred_E0599, r=compiler-errors
[rust.git] / tests / ui / proc-macro / capture-macro-rules-invoke.rs
1 // aux-build:test-macros.rs
2 // check-pass
3 // compile-flags: -Z span-debug
4
5 #![no_std] // Don't load unnecessary hygiene information from std
6 extern crate std;
7
8 extern crate test_macros;
9 use test_macros::{print_bang, print_bang_consume};
10
11 macro_rules! test_matchers {
12     ($expr:expr, $block:block, $stmt:stmt, $ty:ty, $ident:ident, $lifetime:lifetime,
13      $meta:meta, $path:path, $vis:vis, $tt:tt, $lit:literal) => {
14         print_bang_consume!($expr, $block, $stmt, $ty, $ident,
15                             $lifetime, $meta, $path, $vis, $tt, $lit)
16     }
17 }
18
19 macro_rules! use_expr {
20     ($expr:expr) => {
21         print_bang!($expr)
22     }
23 }
24
25 macro_rules! use_pat {
26     ($pat:pat) => {
27         print_bang!($pat)
28     }
29 }
30
31 #[allow(dead_code)]
32 struct Foo;
33 impl Foo {
34     #[allow(dead_code)]
35     fn use_self(self) {
36         drop(use_expr!(self));
37         test_matchers!(
38             1 + 1,
39             { "a" },
40             let a = 1,
41             String,
42             my_name,
43             'a,
44             my_val = 30,
45             std::option::Option,
46             pub(in some::path),
47             [ a b c ],
48             -30
49         );
50     }
51
52     fn with_pat(use_pat!((a, b)): (u32, u32)) {
53         let _ = (a, b);
54     }
55 }
56
57 fn main() {}