diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-02-14 10:07:30 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-14 10:07:30 -0500 |
| commit | c2ea73473411d33336c7535f783dcf26a3bf88e2 (patch) | |
| tree | d1f810133bec11e12ce514e4ef342a8ec4bedec0 /src/libsyntax | |
| parent | 651a5be270d8b3137f91e05803a25d07e034d36f (diff) | |
| parent | b3d73995dac028f287604dbe763b236be154e787 (diff) | |
| download | rust-c2ea73473411d33336c7535f783dcf26a3bf88e2.tar.gz rust-c2ea73473411d33336c7535f783dcf26a3bf88e2.zip | |
Rollup merge of #39730 - jseyfried:fix_empty_seq_rep_ice, r=nrc
macros: fix ICE on certain sequence repetitions Fixes #39709. r? @nrc
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b051928ff9d..2c4fa8e15ed 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -302,11 +302,20 @@ impl<'a> Parser<'a> { if i + 1 < tts.len() { self.tts.push((tts, i + 1)); } - if let TokenTree::Token(sp, tok) = tt { - TokenAndSpan { tok: tok, sp: sp } - } else { - self.tts.push((tt, 0)); - continue + // FIXME(jseyfried): remove after fixing #39390 in #39419. + if self.quote_depth > 0 { + if let TokenTree::Sequence(sp, _) = tt { + self.span_err(sp, "attempted to repeat an expression containing no \ + syntax variables matched as repeating at this depth"); + } + } + match tt { + TokenTree::Token(sp, tok) => TokenAndSpan { tok: tok, sp: sp }, + _ if tt.len() > 0 => { + self.tts.push((tt, 0)); + continue + } + _ => continue, } } else { TokenAndSpan { tok: token::Eof, sp: self.span } |
