Skip to content

Commit

Permalink
Clean up raw identifier handling when recovering tokens from AST.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lymia committed Mar 22, 2018
1 parent ce84a41 commit bfb94ac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/libsyntax/ext/quote.rs
Expand Up @@ -238,8 +238,9 @@ pub mod rt {
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());

Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/tt/transcribe.rs
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/token.rs
Expand Up @@ -236,7 +236,7 @@ impl 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 '>'.
Expand Down

0 comments on commit bfb94ac

Please sign in to comment.