Commit 5659820
authored
Rollup merge of #155182 - fmease:guard-exp-begins-guard, r=petrochenkov
Make the expansion of guard metavars begin guard non-terminals
While investigating something unrelated, I noticed a bug in the impl of unstable feature `macro_guard_matcher` (tracking issue: rust-lang/rust#153104). Namely, the following doesn't compile:
```rs
#![feature(macro_guard_matcher)]
macro_rules! a { ($guard:guard) => { b!($guard); }; }
macro_rules! b { ($guard:guard) => {}; }
a!(if true);
```
```
error: no rules expected `guard` metavariable
--> src/lib.rs:3:41
|
3 | macro_rules! a { ($guard:guard) => { b!($guard); }; }
| ^^^^^^ no rules expected this token in macro call
4 | macro_rules! b { ($guard:guard) => {}; }
| -------------- when calling this macro
5 | a!(if true);
| ----------- in this macro invocation
|
note: while trying to match meta-variable `$guard:guard`
--> src/lib.rs:4:19
|
4 | macro_rules! b { ($guard:guard) => {}; }
| ^^^^^^^^^^^^
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
```
---
While I'm still skeptical of `guard` fragment specifiers in general (although I can't quite pinpoint why), I figured I should fix this issue.0 file changed
0 commit comments