]> git.lizzy.rs Git - rust.git/commitdiff
Clean up raw identifier handling when recovering tokens from AST.
authorLymia Aluysia <lymia@lymiahugs.com>
Thu, 22 Mar 2018 15:34:51 +0000 (10:34 -0500)
committerLymia Aluysia <lymia@lymiahugs.com>
Thu, 22 Mar 2018 15:34:51 +0000 (10:34 -0500)
src/libsyntax/ext/quote.rs
src/libsyntax/ext/tt/transcribe.rs
src/libsyntax/parse/token.rs

index 090b9a354463050256323be1c37254d49f74b216..540a03ff032ffef2527e5395d99cad058fb08975 100644 (file)
@@ -238,8 +238,9 @@ fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> {
                 if i > 0 {
                     inner.push(TokenTree::Token(self.span, token::Colon).into());
                 }
-                inner.push(TokenTree::Token(self.span,
-                                            token::Ident(segment.identifier, false)).into());
+                inner.push(TokenTree::Token(
+                    self.span, token::Token::from_ast_ident(segment.identifier)
+                ).into());
             }
             inner.push(self.tokens.clone());
 
index 0f5855a32259cd8377edefb64576dae65b87611e..3f01d5ec6dd876e1117ea9c030206968d1f3ffbc 100644 (file)
@@ -169,7 +169,7 @@ pub fn transcribe(cx: &ExtCtxt,
                         Ident { ctxt: ident.ctxt.apply_mark(cx.current_expansion.mark), ..ident };
                     sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
                     result.push(TokenTree::Token(sp, token::Dollar).into());
-                    result.push(TokenTree::Token(sp, token::Ident(ident, false)).into());
+                    result.push(TokenTree::Token(sp, token::Token::from_ast_ident(ident)).into());
                 }
             }
             quoted::TokenTree::Delimited(mut span, delimited) => {
index 4e7a282adc5842a38dda60abca5b4ce3e7bdabbe..7798a7a77ee6c8c63e96cd47895759427b6d213b 100644 (file)
@@ -236,7 +236,7 @@ pub fn interpolated(nt: Nonterminal) -> Token {
 
     /// Recovers a `Token` from an `ast::Ident`. This creates a raw identifier if necessary.
     pub fn from_ast_ident(ident: ast::Ident) -> Token {
-        Ident(ident, is_reserved_ident(ident))
+        Ident(ident, is_reserved_ident(ident) && !is_path_segment_keyword(ident))
     }
 
     /// Returns `true` if the token starts with '>'.