about summary refs log tree commit diff
path: root/src/libsyntax/parse/token.rs
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2019-08-01 16:00:26 +0200
committerGitHub <noreply@github.com>2019-08-01 16:00:26 +0200
commit810ffe2ba07320cac7b89af0c2a68048bfb779c9 (patch)
tree41f7ef742d5d0a7cb4bbed18d3b566c7ee497981 /src/libsyntax/parse/token.rs
parente2934bab3ea0e1cdcd15e215629ba0ea17507449 (diff)
parent6551285ccaf1562eb73ca1013730165b4d415d8e (diff)
downloadrust-810ffe2ba07320cac7b89af0c2a68048bfb779c9.tar.gz
rust-810ffe2ba07320cac7b89af0c2a68048bfb779c9.zip
Rollup merge of #63122 - Centril:fix-63115, r=petrochenkov
Account for `maybe_whole_expr` in range patterns

Fixes https://github.com/rust-lang/rust/issues/63115 (fallout from https://github.com/rust-lang/rust/pull/62550).

r? @petrochenkov
Diffstat (limited to 'src/libsyntax/parse/token.rs')
-rw-r--r--src/libsyntax/parse/token.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 472e4b474d6..73adb5c947c 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -476,6 +476,19 @@ impl Token {
         false
     }
 
+    /// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
+    /// That is, is this a pre-parsed expression dropped into the token stream
+    /// (which happens while parsing the result of macro expansion)?
+    crate fn is_whole_expr(&self) -> bool {
+        if let Interpolated(ref nt) = self.kind {
+            if let NtExpr(_) | NtLiteral(_) | NtPath(_) | NtIdent(..) | NtBlock(_) = **nt {
+                return true;
+            }
+        }
+
+        false
+    }
+
     /// Returns `true` if the token is either the `mut` or `const` keyword.
     crate fn is_mutability(&self) -> bool {
         self.is_keyword(kw::Mut) ||