@@ -88,21 +88,10 @@ macro_rules! maybe_recover_from_interpolated_ty_qpath {
88
88
#[ derive( Clone ) ]
89
89
pub struct Parser < ' a > {
90
90
pub sess : & ' a ParseSess ,
91
- /// The current non-normalized token.
91
+ /// The current token.
92
92
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.
101
94
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 ,
106
95
restrictions : Restrictions ,
107
96
/// Used to determine the path to externally loaded source files.
108
97
pub ( super ) directory : Directory ,
@@ -374,9 +363,7 @@ impl<'a> Parser<'a> {
374
363
let mut parser = Parser {
375
364
sess,
376
365
token : Token :: dummy ( ) ,
377
- normalized_token : Token :: dummy ( ) ,
378
366
prev_token : Token :: dummy ( ) ,
379
- normalized_prev_token : Token :: dummy ( ) ,
380
367
restrictions : Restrictions :: empty ( ) ,
381
368
recurse_into_file_modules,
382
369
directory : Directory {
@@ -609,7 +596,7 @@ impl<'a> Parser<'a> {
609
596
Some ( ( first, second) ) if first == expected => {
610
597
let first_span = self . sess . source_map ( ) . start_point ( self . token . span ) ;
611
598
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) ;
613
600
self . bump_with ( Token :: new ( second, second_span) ) ;
614
601
true
615
602
}
@@ -817,23 +804,6 @@ impl<'a> Parser<'a> {
817
804
self . parse_delim_comma_seq ( token:: Paren , f)
818
805
}
819
806
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
-
837
807
/// Advance the parser by one token using provided token as the next one.
838
808
fn bump_with ( & mut self , next_token : Token ) {
839
809
// Bumping after EOF is a bad sign, usually an infinite loop.
@@ -843,9 +813,7 @@ impl<'a> Parser<'a> {
843
813
}
844
814
845
815
// 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) ;
849
817
850
818
// Diagnostics.
851
819
self . expected_tokens . clear ( ) ;
@@ -1005,7 +973,7 @@ impl<'a> Parser<'a> {
1005
973
& mut self . token_cursor . frame ,
1006
974
self . token_cursor . stack . pop ( ) . unwrap ( ) ,
1007
975
) ;
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 ) ;
1009
977
self . bump ( ) ;
1010
978
TokenTree :: Delimited ( frame. span , frame. delim , frame. tree_cursor . stream )
1011
979
}
0 commit comments