Skip to content

Commit bfb94ac

Browse files
committed
Clean up raw identifier handling when recovering tokens from AST.
1 parent ce84a41 commit bfb94ac

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/libsyntax/ext/quote.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,9 @@ pub mod rt {
238238
if i > 0 {
239239
inner.push(TokenTree::Token(self.span, token::Colon).into());
240240
}
241-
inner.push(TokenTree::Token(self.span,
242-
token::Ident(segment.identifier, false)).into());
241+
inner.push(TokenTree::Token(
242+
self.span, token::Token::from_ast_ident(segment.identifier)
243+
).into());
243244
}
244245
inner.push(self.tokens.clone());
245246

src/libsyntax/ext/tt/transcribe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub fn transcribe(cx: &ExtCtxt,
169169
Ident { ctxt: ident.ctxt.apply_mark(cx.current_expansion.mark), ..ident };
170170
sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
171171
result.push(TokenTree::Token(sp, token::Dollar).into());
172-
result.push(TokenTree::Token(sp, token::Ident(ident, false)).into());
172+
result.push(TokenTree::Token(sp, token::Token::from_ast_ident(ident)).into());
173173
}
174174
}
175175
quoted::TokenTree::Delimited(mut span, delimited) => {

src/libsyntax/parse/token.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl Token {
236236

237237
/// Recovers a `Token` from an `ast::Ident`. This creates a raw identifier if necessary.
238238
pub fn from_ast_ident(ident: ast::Ident) -> Token {
239-
Ident(ident, is_reserved_ident(ident))
239+
Ident(ident, is_reserved_ident(ident) && !is_path_segment_keyword(ident))
240240
}
241241

242242
/// Returns `true` if the token starts with '>'.

0 commit comments

Comments
 (0)