1
Fork 0

Capture tokens for Pat used in macro_rules! argument

This extends PR #73293 to handle patterns (Pat). Unlike expressions,
patterns do not support custom attributes, so we only need to capture
tokens during macro_rules! argument parsing.
This commit is contained in:
Aaron Hill 2020-07-27 18:02:29 -04:00
commit 607a190059
No known key found for this signature in database
GPG key ID: B4087E510E98B164
13 changed files with 85 additions and 10 deletions

View file

@ -1,12 +1,20 @@
// aux-build:test-macros.rs
// check-pass
// compile-flags: -Z span-debug
// normalize-stdout-test "#\d+" -> "#CTXT"
extern crate test_macros;
use test_macros::recollect;
use test_macros::print_bang;
macro_rules! use_expr {
($expr:expr) => {
recollect!($expr)
print_bang!($expr)
}
}
macro_rules! use_pat {
($pat:pat) => {
print_bang!($pat)
}
}
@ -17,6 +25,10 @@ impl Foo {
fn use_self(self) {
drop(use_expr!(self));
}
fn with_pat(use_pat!((a, b)): (u32, u32)) {
println!("Args: {} {}", a, b);
}
}
fn main() {}