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:
parent
f6049b60db
commit
607a190059
13 changed files with 85 additions and 10 deletions
|
@ -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() {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue