diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-01-19 09:03:28 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-19 09:03:28 +0100 |
| commit | fd779d3f76240c61104909f237c031ebba9d11df (patch) | |
| tree | a23911d334b7277d42cad73a10db9e008a35f0c2 /src/libsyntax/ext | |
| parent | 64eb69b904513b8f277102e4c802527e718debdc (diff) | |
| parent | aa1ce32b105ff506257019a22684a98b61ab166a (diff) | |
| download | rust-fd779d3f76240c61104909f237c031ebba9d11df.tar.gz rust-fd779d3f76240c61104909f237c031ebba9d11df.zip | |
Rollup merge of #57610 - mark-i-m:nested-matchers, r=petrochenkov
Fix nested `?` matchers fix #57597 I'm not 100% if this works yet... cc @alercah When this is ready (but perhaps not yet):
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 24202ca8fbd..9a129e7e8fc 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -435,7 +435,8 @@ fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[quoted::TokenTree]) -> bool { match *seq_tt { TokenTree::MetaVarDecl(_, _, id) => id.name == "vis", TokenTree::Sequence(_, ref sub_seq) => - sub_seq.op == quoted::KleeneOp::ZeroOrMore, + sub_seq.op == quoted::KleeneOp::ZeroOrMore + || sub_seq.op == quoted::KleeneOp::ZeroOrOne, _ => false, } }) { @@ -543,7 +544,10 @@ impl FirstSets { } // Reverse scan: Sequence comes before `first`. - if subfirst.maybe_empty || seq_rep.op == quoted::KleeneOp::ZeroOrMore { + if subfirst.maybe_empty + || seq_rep.op == quoted::KleeneOp::ZeroOrMore + || seq_rep.op == quoted::KleeneOp::ZeroOrOne + { // If sequence is potentially empty, then // union them (preserving first emptiness). first.add_all(&TokenSet { maybe_empty: true, ..subfirst }); @@ -591,8 +595,10 @@ impl FirstSets { assert!(first.maybe_empty); first.add_all(subfirst); - if subfirst.maybe_empty || - seq_rep.op == quoted::KleeneOp::ZeroOrMore { + if subfirst.maybe_empty + || seq_rep.op == quoted::KleeneOp::ZeroOrMore + || seq_rep.op == quoted::KleeneOp::ZeroOrOne + { // continue scanning for more first // tokens, but also make sure we // restore empty-tracking state |
