diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2017-11-27 23:07:44 -0800 |
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2017-11-28 18:59:12 -0800 |
| commit | dfa6c25afd911d30bd0620bed97bdcc23bd8de42 (patch) | |
| tree | 93c2ae5c2b8831429ecc7a9a5ff872b9ca6797bc /src/libsyntax | |
| parent | 560a5da9f1cc7f67d2fc372925aef18c96c82629 (diff) | |
| download | rust-dfa6c25afd911d30bd0620bed97bdcc23bd8de42.tar.gz rust-dfa6c25afd911d30bd0620bed97bdcc23bd8de42.zip | |
Fix hygiene bug.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 951163d35fa..6f20104dda5 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -73,6 +73,13 @@ impl<'a> StringReader<'a> { fn mk_sp(&self, lo: BytePos, hi: BytePos) -> Span { unwrap_or!(self.override_span, Span::new(lo, hi, NO_EXPANSION)) } + fn mk_ident(&self, string: &str) -> Ident { + let mut ident = Ident::from_str(string); + if let Some(span) = self.override_span { + ident.ctxt = span.ctxt(); + } + ident + } fn next_token(&mut self) -> TokenAndSpan where Self: Sized { let res = self.try_next_token(); @@ -1103,7 +1110,7 @@ impl<'a> StringReader<'a> { token::Underscore } else { // FIXME: perform NFKC normalization here. (Issue #2253) - token::Ident(Ident::from_str(string)) + token::Ident(self.mk_ident(string)) } })); } @@ -1286,13 +1293,13 @@ impl<'a> StringReader<'a> { // expansion purposes. See #12512 for the gory details of why // this is necessary. let ident = self.with_str_from(start, |lifetime_name| { - Ident::from_str(&format!("'{}", lifetime_name)) + self.mk_ident(&format!("'{}", lifetime_name)) }); // Conjure up a "keyword checking ident" to make sure that // the lifetime name is not a keyword. let keyword_checking_ident = self.with_str_from(start, |lifetime_name| { - Ident::from_str(lifetime_name) + self.mk_ident(lifetime_name) }); let keyword_checking_token = &token::Ident(keyword_checking_ident); let last_bpos = self.pos; |
