From 3b8f791bf60c0e77ec713356e841c836eb6a55fb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 May 2018 09:02:50 -0700 Subject: rustc: Fix procedural macros generating lifetime tokens This commit fixes an accidental regression from #50473 where lifetime tokens produced by procedural macros ended up getting lost in translation in the compiler and not actually producing parseable code. The issue lies in the fact that a lifetime's `Ident` is prefixed with `'`. The `glue` implementation for gluing joint tokens together forgot to take this into account so the lifetime inside of `Ident` was missing the leading tick! The `glue` implementation here is updated to create a new `Symbol` in these situations to manufacture a new `Ident` with a leading tick to ensure it parses correctly. Closes #50942 --- src/libsyntax/parse/token.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 5575614a4d4..06af21b3747 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -22,6 +22,7 @@ use serialize::{Decodable, Decoder, Encodable, Encoder}; use symbol::keywords; use syntax::parse::parse_stream_from_source_str; use syntax_pos::{self, Span, FileName}; +use syntax_pos::symbol::{self, Symbol}; use tokenstream::{TokenStream, TokenTree}; use tokenstream; @@ -478,7 +479,13 @@ impl Token { _ => return None, }, SingleQuote => match joint { - Ident(ident, false) => Lifetime(ident), + Ident(ident, false) => { + let name = Symbol::intern(&format!("'{}", ident)); + Lifetime(symbol::Ident { + name, + span: ident.span, + }) + } _ => return None, }, -- cgit 1.4.1-3-g733a5