@@ -12,7 +12,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1212use rustc_data_structures:: sync:: Lrc ;
1313use rustc_macros:: HashStable_Generic ;
1414use rustc_span:: symbol:: kw;
15- use rustc_span:: symbol:: Symbol ;
15+ use rustc_span:: symbol:: { Ident , Symbol } ;
1616use rustc_span:: { self , Span , DUMMY_SP } ;
1717use std:: borrow:: Cow ;
1818use std:: { fmt, mem} ;
@@ -145,7 +145,7 @@ impl Lit {
145145 }
146146}
147147
148- pub fn ident_can_begin_expr ( name : ast :: Name , span : Span , is_raw : bool ) -> bool {
148+ pub fn ident_can_begin_expr ( name : Symbol , span : Span , is_raw : bool ) -> bool {
149149 let ident_token = Token :: new ( Ident ( name, is_raw) , span) ;
150150
151151 !ident_token. is_reserved_ident ( )
@@ -173,7 +173,7 @@ pub fn ident_can_begin_expr(name: ast::Name, span: Span, is_raw: bool) -> bool {
173173 . contains ( & name)
174174}
175175
176- fn ident_can_begin_type ( name : ast :: Name , span : Span , is_raw : bool ) -> bool {
176+ fn ident_can_begin_type ( name : Symbol , span : Span , is_raw : bool ) -> bool {
177177 let ident_token = Token :: new ( Ident ( name, is_raw) , span) ;
178178
179179 !ident_token. is_reserved_ident ( )
@@ -229,18 +229,18 @@ pub enum TokenKind {
229229 /// Do not forget about `NtIdent` when you want to match on identifiers.
230230 /// It's recommended to use `Token::(ident,uninterpolate,uninterpolated_span)` to
231231 /// treat regular and interpolated identifiers in the same way.
232- Ident ( ast :: Name , /* is_raw */ bool ) ,
232+ Ident ( Symbol , /* is_raw */ bool ) ,
233233 /// Lifetime identifier token.
234234 /// Do not forget about `NtLifetime` when you want to match on lifetime identifiers.
235235 /// It's recommended to use `Token::(lifetime,uninterpolate,uninterpolated_span)` to
236236 /// treat regular and interpolated lifetime identifiers in the same way.
237- Lifetime ( ast :: Name ) ,
237+ Lifetime ( Symbol ) ,
238238
239239 Interpolated ( Lrc < Nonterminal > ) ,
240240
241241 // Can be expanded into several tokens.
242242 /// A doc comment.
243- DocComment ( ast :: Name ) ,
243+ DocComment ( Symbol ) ,
244244
245245 // Junk. These carry no data because we don't really care about the data
246246 // they *would* carry, and don't really want to allocate a new ident for
@@ -249,9 +249,9 @@ pub enum TokenKind {
249249 Whitespace ,
250250 /// A comment.
251251 Comment ,
252- Shebang ( ast :: Name ) ,
252+ Shebang ( Symbol ) ,
253253 /// A completely invalid token which should be skipped.
254- Unknown ( ast :: Name ) ,
254+ Unknown ( Symbol ) ,
255255
256256 Eof ,
257257}
@@ -325,8 +325,8 @@ impl Token {
325325 Token :: new ( TokenKind :: Whitespace , DUMMY_SP )
326326 }
327327
328- /// Recovers a `Token` from an `ast:: Ident`. This creates a raw identifier if necessary.
329- pub fn from_ast_ident ( ident : ast :: Ident ) -> Self {
328+ /// Recovers a `Token` from an `Ident`. This creates a raw identifier if necessary.
329+ pub fn from_ast_ident ( ident : Ident ) -> Self {
330330 Token :: new ( Ident ( ident. name , ident. is_raw_guess ( ) ) , ident. span )
331331 }
332332
@@ -488,19 +488,19 @@ impl Token {
488488 }
489489
490490 /// Returns an identifier if this token is an identifier.
491- pub fn ident ( & self ) -> Option < ( ast :: Ident , /* is_raw */ bool ) > {
491+ pub fn ident ( & self ) -> Option < ( Ident , /* is_raw */ bool ) > {
492492 let token = self . uninterpolate ( ) ;
493493 match token. kind {
494- Ident ( name, is_raw) => Some ( ( ast :: Ident :: new ( name, token. span ) , is_raw) ) ,
494+ Ident ( name, is_raw) => Some ( ( Ident :: new ( name, token. span ) , is_raw) ) ,
495495 _ => None ,
496496 }
497497 }
498498
499499 /// Returns a lifetime identifier if this token is a lifetime.
500- pub fn lifetime ( & self ) -> Option < ast :: Ident > {
500+ pub fn lifetime ( & self ) -> Option < Ident > {
501501 let token = self . uninterpolate ( ) ;
502502 match token. kind {
503- Lifetime ( name) => Some ( ast :: Ident :: new ( name, token. span ) ) ,
503+ Lifetime ( name) => Some ( Ident :: new ( name, token. span ) ) ,
504504 _ => None ,
505505 }
506506 }
@@ -577,28 +577,28 @@ impl Token {
577577 }
578578
579579 pub fn is_path_segment_keyword ( & self ) -> bool {
580- self . is_non_raw_ident_where ( ast :: Ident :: is_path_segment_keyword)
580+ self . is_non_raw_ident_where ( Ident :: is_path_segment_keyword)
581581 }
582582
583583 // Returns true for reserved identifiers used internally for elided lifetimes,
584584 // unnamed method parameters, crate root module, error recovery etc.
585585 pub fn is_special_ident ( & self ) -> bool {
586- self . is_non_raw_ident_where ( ast :: Ident :: is_special)
586+ self . is_non_raw_ident_where ( Ident :: is_special)
587587 }
588588
589589 /// Returns `true` if the token is a keyword used in the language.
590590 pub fn is_used_keyword ( & self ) -> bool {
591- self . is_non_raw_ident_where ( ast :: Ident :: is_used_keyword)
591+ self . is_non_raw_ident_where ( Ident :: is_used_keyword)
592592 }
593593
594594 /// Returns `true` if the token is a keyword reserved for possible future use.
595595 pub fn is_unused_keyword ( & self ) -> bool {
596- self . is_non_raw_ident_where ( ast :: Ident :: is_unused_keyword)
596+ self . is_non_raw_ident_where ( Ident :: is_unused_keyword)
597597 }
598598
599599 /// Returns `true` if the token is either a special identifier or a keyword.
600600 pub fn is_reserved_ident ( & self ) -> bool {
601- self . is_non_raw_ident_where ( ast :: Ident :: is_reserved)
601+ self . is_non_raw_ident_where ( Ident :: is_reserved)
602602 }
603603
604604 /// Returns `true` if the token is the identifier `true` or `false`.
@@ -607,7 +607,7 @@ impl Token {
607607 }
608608
609609 /// Returns `true` if the token is a non-raw identifier for which `pred` holds.
610- pub fn is_non_raw_ident_where ( & self , pred : impl FnOnce ( ast :: Ident ) -> bool ) -> bool {
610+ pub fn is_non_raw_ident_where ( & self , pred : impl FnOnce ( Ident ) -> bool ) -> bool {
611611 match self . ident ( ) {
612612 Some ( ( id, false ) ) => pred ( id) ,
613613 _ => false ,
@@ -746,8 +746,8 @@ pub enum Nonterminal {
746746 NtPat ( P < ast:: Pat > ) ,
747747 NtExpr ( P < ast:: Expr > ) ,
748748 NtTy ( P < ast:: Ty > ) ,
749- NtIdent ( ast :: Ident , /* is_raw */ bool ) ,
750- NtLifetime ( ast :: Ident ) ,
749+ NtIdent ( Ident , /* is_raw */ bool ) ,
750+ NtLifetime ( Ident ) ,
751751 NtLiteral ( P < ast:: Expr > ) ,
752752 /// Stuff inside brackets for attributes
753753 NtMeta ( P < ast:: AttrItem > ) ,
0 commit comments