diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-10-19 23:33:41 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-10-20 20:28:10 +0300 |
| commit | fea630ef9d738aabaf6cbf3ccedb1bc1adae1e6d (patch) | |
| tree | ffb16874f8f8c6b7ccf16239bfd1a58f5cfe7f1c /src/libsyntax/parse/token.rs | |
| parent | 65ff4ca2948301f59b6a6eab14234d005378859a (diff) | |
| download | rust-fea630ef9d738aabaf6cbf3ccedb1bc1adae1e6d.tar.gz rust-fea630ef9d738aabaf6cbf3ccedb1bc1adae1e6d.zip | |
Tweak path parsing logic
Diffstat (limited to 'src/libsyntax/parse/token.rs')
| -rw-r--r-- | src/libsyntax/parse/token.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 26b5b99c8cc..4d0da660302 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -159,10 +159,8 @@ impl Token { /// Returns `true` if the token can appear at the start of an expression. pub fn can_begin_expr(&self) -> bool { match *self { - OpenDelim(_) => true, + OpenDelim(..) => true, Ident(..) => true, - Underscore => true, - Tilde => true, Literal(..) => true, Not => true, BinOp(Minus) => true, @@ -172,6 +170,7 @@ impl Token { OrOr => true, // in lambda syntax AndAnd => true, // double borrow DotDot | DotDotDot => true, // range notation + Lt | BinOp(Shl) => true, // associated path ModSep => true, Interpolated(NtExpr(..)) => true, Interpolated(NtIdent(..)) => true, @@ -236,8 +235,12 @@ impl Token { self.is_keyword(keywords::Const) } + pub fn is_qpath_start(&self) -> bool { + self == &Lt || self == &BinOp(Shl) + } + pub fn is_path_start(&self) -> bool { - self == &ModSep || self == &Lt || self.is_path() || + self == &ModSep || self.is_qpath_start() || self.is_path() || self.is_path_segment_keyword() || self.is_ident() && !self.is_any_keyword() } |
