@@ -88,21 +88,10 @@ macro_rules! maybe_recover_from_interpolated_ty_qpath {
8888#[ derive( Clone ) ]
8989pub struct Parser < ' a > {
9090 pub sess : & ' a ParseSess ,
91- /// The current non-normalized token.
91+ /// The current token.
9292 pub token : Token ,
93- /// The current normalized token.
94- /// "Normalized" means that some interpolated tokens
95- /// (`$i: ident` and `$l: lifetime` meta-variables) are replaced
96- /// with non-interpolated identifier and lifetime tokens they refer to.
97- /// Use this if you need to check for `token::Ident` or `token::Lifetime` specifically,
98- /// this also includes edition checks for edition-specific keyword identifiers.
99- pub normalized_token : Token ,
100- /// The previous non-normalized token.
93+ /// The previous token.
10194 pub prev_token : Token ,
102- /// The previous normalized token.
103- /// Use this if you need to check for `token::Ident` or `token::Lifetime` specifically,
104- /// this also includes edition checks for edition-specific keyword identifiers.
105- pub normalized_prev_token : Token ,
10695 restrictions : Restrictions ,
10796 /// Used to determine the path to externally loaded source files.
10897 pub ( super ) directory : Directory ,
@@ -374,9 +363,7 @@ impl<'a> Parser<'a> {
374363 let mut parser = Parser {
375364 sess,
376365 token : Token :: dummy ( ) ,
377- normalized_token : Token :: dummy ( ) ,
378366 prev_token : Token :: dummy ( ) ,
379- normalized_prev_token : Token :: dummy ( ) ,
380367 restrictions : Restrictions :: empty ( ) ,
381368 recurse_into_file_modules,
382369 directory : Directory {
@@ -609,7 +596,7 @@ impl<'a> Parser<'a> {
609596 Some ( ( first, second) ) if first == expected => {
610597 let first_span = self . sess . source_map ( ) . start_point ( self . token . span ) ;
611598 let second_span = self . token . span . with_lo ( first_span. hi ( ) ) ;
612- self . set_token ( Token :: new ( first, first_span) ) ;
599+ self . token = Token :: new ( first, first_span) ;
613600 self . bump_with ( Token :: new ( second, second_span) ) ;
614601 true
615602 }
@@ -817,23 +804,6 @@ impl<'a> Parser<'a> {
817804 self . parse_delim_comma_seq ( token:: Paren , f)
818805 }
819806
820- // Interpolated identifier (`$i: ident`) and lifetime (`$l: lifetime`)
821- // tokens are replaced with usual identifier and lifetime tokens,
822- // so the former are never encountered during normal parsing.
823- crate fn set_token ( & mut self , token : Token ) {
824- self . token = token;
825- self . normalized_token = match & self . token . kind {
826- token:: Interpolated ( nt) => match * * nt {
827- token:: NtIdent ( ident, is_raw) => {
828- Token :: new ( token:: Ident ( ident. name , is_raw) , ident. span )
829- }
830- token:: NtLifetime ( ident) => Token :: new ( token:: Lifetime ( ident. name ) , ident. span ) ,
831- _ => self . token . clone ( ) ,
832- } ,
833- _ => self . token . clone ( ) ,
834- }
835- }
836-
837807 /// Advance the parser by one token using provided token as the next one.
838808 fn bump_with ( & mut self , next_token : Token ) {
839809 // Bumping after EOF is a bad sign, usually an infinite loop.
@@ -843,9 +813,7 @@ impl<'a> Parser<'a> {
843813 }
844814
845815 // Update the current and previous tokens.
846- self . prev_token = self . token . take ( ) ;
847- self . normalized_prev_token = self . normalized_token . take ( ) ;
848- self . set_token ( next_token) ;
816+ self . prev_token = mem:: replace ( & mut self . token , next_token) ;
849817
850818 // Diagnostics.
851819 self . expected_tokens . clear ( ) ;
@@ -1005,7 +973,7 @@ impl<'a> Parser<'a> {
1005973 & mut self . token_cursor . frame ,
1006974 self . token_cursor . stack . pop ( ) . unwrap ( ) ,
1007975 ) ;
1008- self . set_token ( Token :: new ( TokenKind :: CloseDelim ( frame. delim ) , frame. span . close ) ) ;
976+ self . token = Token :: new ( TokenKind :: CloseDelim ( frame. delim ) , frame. span . close ) ;
1009977 self . bump ( ) ;
1010978 TokenTree :: Delimited ( frame. span , frame. delim , frame. tree_cursor . stream )
1011979 }
0 commit comments