diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-05 11:56:06 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-06 14:04:02 +0300 |
| commit | f745e5f9b676be02cc1dfbab0bfb338dc72b4dd3 (patch) | |
| tree | a4982d98a51c2f8358495b9b60e3a059a9e9c1cd /src/libsyntax_pos | |
| parent | 4c5d773b4d529c6263f682513ea34ce644a8179b (diff) | |
| download | rust-f745e5f9b676be02cc1dfbab0bfb338dc72b4dd3.tar.gz rust-f745e5f9b676be02cc1dfbab0bfb338dc72b4dd3.zip | |
syntax: Remove duplicate span from `token::Ident`
Diffstat (limited to 'src/libsyntax_pos')
| -rw-r--r-- | src/libsyntax_pos/symbol.rs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 4e080d115d2..c37aae0bf31 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -1019,6 +1019,21 @@ impl Symbol { pub fn is_doc_keyword(self) -> bool { self <= kw::Union } + + /// A keyword or reserved identifier that can be used as a path segment. + pub fn is_path_segment_keyword(self) -> bool { + self == kw::Super || + self == kw::SelfLower || + self == kw::SelfUpper || + self == kw::Crate || + self == kw::PathRoot || + self == kw::DollarCrate + } + + /// This symbol can be a raw identifier. + pub fn can_be_raw(self) -> bool { + self != kw::Invalid && self != kw::Underscore && !self.is_path_segment_keyword() + } } impl Ident { @@ -1049,24 +1064,13 @@ impl Ident { /// A keyword or reserved identifier that can be used as a path segment. pub fn is_path_segment_keyword(self) -> bool { - self.name == kw::Super || - self.name == kw::SelfLower || - self.name == kw::SelfUpper || - self.name == kw::Crate || - self.name == kw::PathRoot || - self.name == kw::DollarCrate - } - - /// This identifier can be a raw identifier. - pub fn can_be_raw(self) -> bool { - self.name != kw::Invalid && self.name != kw::Underscore && - !self.is_path_segment_keyword() + self.name.is_path_segment_keyword() } /// We see this identifier in a normal identifier position, like variable name or a type. /// How was it written originally? Did it use the raw form? Let's try to guess. pub fn is_raw_guess(self) -> bool { - self.can_be_raw() && self.is_reserved() + self.name.can_be_raw() && self.is_reserved() } } |
