From 2d4b633be36a59667f8648d987169f59f8314b1c Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 30 Nov 2018 22:34:24 +0300 Subject: Delay gensym creation for "underscore items" until name resolution Prohibit `static _` Fis unused import warnings for `use foo as _` Add more tests for `use foo as _` --- src/libsyntax_pos/symbol.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/libsyntax_pos') diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 741877bb4c8..2721ab70e22 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -80,6 +80,10 @@ impl Ident { Ident::new(self.name.gensymed(), self.span) } + pub fn gensym_if_underscore(self) -> Ident { + if self.name == keywords::Underscore.name() { self.gensym() } else { self } + } + pub fn as_str(self) -> LocalInternedString { self.name.as_str() } @@ -465,7 +469,7 @@ impl Ident { // We see this identifier in a normal identifier position, like variable name or a type. // How was it written originally? Did it use the raw form? Let's try to guess. pub fn is_raw_guess(self) -> bool { - self.name != keywords::Invalid.name() && + self.name != keywords::Invalid.name() && self.name != keywords::Underscore.name() && self.is_reserved() && !self.is_path_segment_keyword() } } -- cgit 1.4.1-3-g733a5