diff options
| author | Pietro Albini <pietro@pietroalbini.org> | 2019-08-01 16:00:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-01 16:00:26 +0200 |
| commit | 810ffe2ba07320cac7b89af0c2a68048bfb779c9 (patch) | |
| tree | 41f7ef742d5d0a7cb4bbed18d3b566c7ee497981 /src/libsyntax/parse/token.rs | |
| parent | e2934bab3ea0e1cdcd15e215629ba0ea17507449 (diff) | |
| parent | 6551285ccaf1562eb73ca1013730165b4d415d8e (diff) | |
| download | rust-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.rs | 13 |
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) || |
