about summary refs log tree commit diff
path: root/src/librustc_parse/parser/diagnostics.rs
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-03-04 23:37:52 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-03-09 12:42:41 +0300
commit925e9a2188dcd6e1988ceaa3ab8d64fcdb3d6d1e (patch)
tree245d7c2b396a68d2580f9defc4ec04232aef94ba /src/librustc_parse/parser/diagnostics.rs
parent2cb0b8582ebbf9784db9cec06fff517badbf4553 (diff)
downloadrust-925e9a2188dcd6e1988ceaa3ab8d64fcdb3d6d1e.tar.gz
rust-925e9a2188dcd6e1988ceaa3ab8d64fcdb3d6d1e.zip
rustc_parse: Use `Token::ident` where possible
Diffstat (limited to 'src/librustc_parse/parser/diagnostics.rs')
-rw-r--r--src/librustc_parse/parser/diagnostics.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs
index 6587e763d50..7c1df531ad1 100644
--- a/src/librustc_parse/parser/diagnostics.rs
+++ b/src/librustc_parse/parser/diagnostics.rs
@@ -192,17 +192,19 @@ impl<'a> Parser<'a> {
             TokenKind::CloseDelim(token::DelimToken::Brace),
             TokenKind::CloseDelim(token::DelimToken::Paren),
         ];
-        if let token::Ident(name, false) = self.normalized_token.kind {
-            if Ident::new(name, self.normalized_token.span).is_raw_guess()
-                && self.look_ahead(1, |t| valid_follow.contains(&t.kind))
+        match self.token.ident() {
+            Some((ident, false))
+                if ident.is_raw_guess()
+                    && self.look_ahead(1, |t| valid_follow.contains(&t.kind)) =>
             {
                 err.span_suggestion(
-                    self.normalized_token.span,
+                    ident.span,
                     "you can escape reserved keywords to use them as identifiers",
-                    format!("r#{}", name),
+                    format!("r#{}", ident.name),
                     Applicability::MaybeIncorrect,
                 );
             }
+            _ => {}
         }
         if let Some(token_descr) = super::token_descr_opt(&self.token) {
             err.span_label(self.token.span, format!("expected identifier, found {}", token_descr));