about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-02-27 22:06:26 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-03-16 23:13:15 +0300
commit6ad55b3decefd53263f20a6c575aaa85c1edcbec (patch)
tree6ad909da93cbfe48a004e134ea296ada6f84ee42 /src/libsyntax/parse
parent5cb5083909f19c107aec186a72b8b9104f8ca30d (diff)
downloadrust-6ad55b3decefd53263f20a6c575aaa85c1edcbec.tar.gz
rust-6ad55b3decefd53263f20a6c575aaa85c1edcbec.zip
syntax: Introduce `Ident::can_be_raw`
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/lexer/mod.rs12
-rw-r--r--src/libsyntax/parse/parser.rs4
2 files changed, 5 insertions, 11 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs
index 01e3b292903..bcd53dbfeb2 100644
--- a/src/libsyntax/parse/lexer/mod.rs
+++ b/src/libsyntax/parse/lexer/mod.rs
@@ -1,7 +1,7 @@
 use crate::ast::{self, Ident};
 use crate::source_map::{SourceMap, FilePathMapping};
 use crate::parse::{token, ParseSess};
-use crate::symbol::{Symbol, keywords};
+use crate::symbol::Symbol;
 
 use errors::{Applicability, FatalError, Diagnostic, DiagnosticBuilder};
 use syntax_pos::{BytePos, CharPos, Pos, Span, NO_EXPANSION};
@@ -1249,15 +1249,11 @@ impl<'a> StringReader<'a> {
                     // FIXME: perform NFKC normalization here. (Issue #2253)
                     let ident = self.mk_ident(string);
 
-                    if is_raw_ident && (ident.is_path_segment_keyword() ||
-                                        ident.name == keywords::Underscore.name()) {
-                        self.fatal_span_(raw_start, self.pos,
-                            &format!("`r#{}` is not currently supported.", ident.name)
-                        ).raise();
-                    }
-
                     if is_raw_ident {
                         let span = self.mk_sp(raw_start, self.pos);
+                        if !ident.can_be_raw() {
+                            self.err_span(span, &format!("`{}` cannot be a raw identifier", ident));
+                        }
                         self.sess.raw_identifier_spans.borrow_mut().push(span);
                     }
 
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 22af7d47fd0..b9510dc08b0 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -895,9 +895,7 @@ impl<'a> Parser<'a> {
                                            &format!("expected identifier, found {}",
                                                     self.this_token_descr()));
         if let token::Ident(ident, false) = &self.token {
-            if ident.is_reserved() && !ident.is_path_segment_keyword() &&
-                ident.name != keywords::Underscore.name()
-            {
+            if ident.is_raw_guess() {
                 err.span_suggestion(
                     self.span,
                     "you can escape reserved keywords to use them as identifiers",