diff options
| author | Kevin Ballard <kevin@sb.org> | 2014-05-25 18:33:52 -0700 |
|---|---|---|
| committer | Kevin Ballard <kevin@sb.org> | 2014-05-25 22:33:12 -0700 |
| commit | ff0f9b62f64cea6474e93667f93b91c05e3be57f (patch) | |
| tree | f8849c1b7a40ca8d0782395207004b2cddfa88ee /src/libsyntax/parse/parser.rs | |
| parent | 759517c180857e1b494486d810c882755a1e2e26 (diff) | |
| download | rust-ff0f9b62f64cea6474e93667f93b91c05e3be57f.tar.gz rust-ff0f9b62f64cea6474e93667f93b91c05e3be57f.zip | |
Allow $foo:block nonterminals in expression position
Fixes #13678.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index bfdf0361f05..ae5f16c2580 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -135,17 +135,21 @@ at INTERPOLATED tokens */ macro_rules! maybe_whole_expr ( ($p:expr) => ( { - let mut maybe_path = match ($p).token { - INTERPOLATED(token::NtPath(ref pt)) => Some((**pt).clone()), - _ => None, - }; - let found = match ($p).token { + let found = match $p.token { INTERPOLATED(token::NtExpr(e)) => { Some(e) } INTERPOLATED(token::NtPath(_)) => { - let pt = maybe_path.take_unwrap(); - Some($p.mk_expr(($p).span.lo, ($p).span.hi, ExprPath(pt))) + // FIXME: The following avoids an issue with lexical borrowck scopes, + // but the clone is unfortunate. + let pt = match $p.token { + INTERPOLATED(token::NtPath(ref pt)) => (**pt).clone(), + _ => unreachable!() + }; + Some($p.mk_expr($p.span.lo, $p.span.hi, ExprPath(pt))) + } + INTERPOLATED(token::NtBlock(b)) => { + Some($p.mk_expr($p.span.lo, $p.span.hi, ExprBlock(b))) } _ => None }; |
