about summary refs log tree commit diff
path: root/src/libsyntax/parse/token.rs
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2016-04-21 02:03:29 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2016-04-24 20:59:44 +0300
commita97f60ee8618fde7bafe49d79a3ea670758e6a0c (patch)
treeff11f35da542fcbf667cd3f70e4b32402618870b /src/libsyntax/parse/token.rs
parent6c44bea64435fd3859439a6ecab7758855a13f07 (diff)
downloadrust-a97f60ee8618fde7bafe49d79a3ea670758e6a0c.tar.gz
rust-a97f60ee8618fde7bafe49d79a3ea670758e6a0c.zip
syntax: Make `is_path_start` precise and improve some error messages about unexpected tokens
Diffstat (limited to 'src/libsyntax/parse/token.rs')
-rw-r--r--src/libsyntax/parse/token.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 32078c875be..fcb6c3539db 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -243,6 +243,11 @@ impl Token {
         self.is_keyword(keywords::Const)
     }
 
+    pub fn is_path_start(&self) -> bool {
+        self == &ModSep || self == &Lt || self.is_path() ||
+        self.is_path_segment_keyword() || self.is_ident() && !self.is_any_keyword()
+    }
+
     /// Maps a token to its corresponding binary operator.
     pub fn to_binop(&self) -> Option<BinOpKind> {
         match *self {