@@ -261,19 +261,19 @@ struct CaptureState {
261
261
262
262
/// A sequence separator.
263
263
#[ derive( Debug ) ]
264
- struct SeqSep < ' a > {
264
+ struct SeqSep {
265
265
/// The separator token.
266
- sep : Option < ExpTokenPair < ' a > > ,
266
+ sep : Option < ExpTokenPair > ,
267
267
/// `true` if a trailing separator is allowed.
268
268
trailing_sep_allowed : bool ,
269
269
}
270
270
271
- impl < ' a > SeqSep < ' a > {
272
- fn trailing_allowed ( sep : ExpTokenPair < ' a > ) -> SeqSep < ' a > {
271
+ impl SeqSep {
272
+ fn trailing_allowed ( sep : ExpTokenPair ) -> SeqSep {
273
273
SeqSep { sep : Some ( sep) , trailing_sep_allowed : true }
274
274
}
275
275
276
- fn none ( ) -> SeqSep < ' a > {
276
+ fn none ( ) -> SeqSep {
277
277
SeqSep { sep : None , trailing_sep_allowed : false }
278
278
}
279
279
}
@@ -425,13 +425,13 @@ impl<'a> Parser<'a> {
425
425
}
426
426
427
427
/// Expects and consumes the token `t`. Signals an error if the next token is not `t`.
428
- pub fn expect ( & mut self , exp : ExpTokenPair < ' _ > ) -> PResult < ' a , Recovered > {
428
+ pub fn expect ( & mut self , exp : ExpTokenPair ) -> PResult < ' a , Recovered > {
429
429
if self . expected_token_types . is_empty ( ) {
430
- if self . token == * exp. tok {
430
+ if self . token == exp. tok {
431
431
self . bump ( ) ;
432
432
Ok ( Recovered :: No )
433
433
} else {
434
- self . unexpected_try_recover ( exp. tok )
434
+ self . unexpected_try_recover ( & exp. tok )
435
435
}
436
436
} else {
437
437
self . expect_one_of ( slice:: from_ref ( & exp) , & [ ] )
@@ -443,13 +443,13 @@ impl<'a> Parser<'a> {
443
443
/// anything. Signal a fatal error if next token is unexpected.
444
444
fn expect_one_of (
445
445
& mut self ,
446
- edible : & [ ExpTokenPair < ' _ > ] ,
447
- inedible : & [ ExpTokenPair < ' _ > ] ,
446
+ edible : & [ ExpTokenPair ] ,
447
+ inedible : & [ ExpTokenPair ] ,
448
448
) -> PResult < ' a , Recovered > {
449
- if edible. iter ( ) . any ( |exp| exp. tok == & self . token . kind ) {
449
+ if edible. iter ( ) . any ( |exp| exp. tok == self . token . kind ) {
450
450
self . bump ( ) ;
451
451
Ok ( Recovered :: No )
452
- } else if inedible. iter ( ) . any ( |exp| exp. tok == & self . token . kind ) {
452
+ } else if inedible. iter ( ) . any ( |exp| exp. tok == self . token . kind ) {
453
453
// leave it in the input
454
454
Ok ( Recovered :: No )
455
455
} else if self . token != token:: Eof
@@ -494,8 +494,8 @@ impl<'a> Parser<'a> {
494
494
/// This method will automatically add `tok` to `expected_token_types` if `tok` is not
495
495
/// encountered.
496
496
#[ inline]
497
- pub fn check ( & mut self , exp : ExpTokenPair < ' _ > ) -> bool {
498
- let is_present = self . token == * exp. tok ;
497
+ pub fn check ( & mut self , exp : ExpTokenPair ) -> bool {
498
+ let is_present = self . token == exp. tok ;
499
499
if !is_present {
500
500
self . expected_token_types . insert ( exp. token_type ) ;
501
501
}
@@ -542,7 +542,7 @@ impl<'a> Parser<'a> {
542
542
/// Consumes a token 'tok' if it exists. Returns whether the given token was present.
543
543
#[ inline]
544
544
#[ must_use]
545
- pub fn eat ( & mut self , exp : ExpTokenPair < ' _ > ) -> bool {
545
+ pub fn eat ( & mut self , exp : ExpTokenPair ) -> bool {
546
546
let is_present = self . check ( exp) ;
547
547
if is_present {
548
548
self . bump ( )
@@ -745,13 +745,13 @@ impl<'a> Parser<'a> {
745
745
/// Eats the expected token if it's present possibly breaking
746
746
/// compound tokens like multi-character operators in process.
747
747
/// Returns `true` if the token was eaten.
748
- fn break_and_eat ( & mut self , exp : ExpTokenPair < ' _ > ) -> bool {
749
- if self . token == * exp. tok {
748
+ fn break_and_eat ( & mut self , exp : ExpTokenPair ) -> bool {
749
+ if self . token == exp. tok {
750
750
self . bump ( ) ;
751
751
return true ;
752
752
}
753
753
match self . token . kind . break_two_token_op ( 1 ) {
754
- Some ( ( first, second) ) if first == * exp. tok => {
754
+ Some ( ( first, second) ) if first == exp. tok => {
755
755
let first_span = self . psess . source_map ( ) . start_point ( self . token . span ) ;
756
756
let second_span = self . token . span . with_lo ( first_span. hi ( ) ) ;
757
757
self . token = Token :: new ( first, first_span) ;
@@ -826,7 +826,7 @@ impl<'a> Parser<'a> {
826
826
/// Checks if the next token is contained within `closes`, and returns `true` if so.
827
827
fn expect_any_with_type (
828
828
& mut self ,
829
- closes_expected : & [ ExpTokenPair < ' _ > ] ,
829
+ closes_expected : & [ ExpTokenPair ] ,
830
830
closes_not_expected : & [ & TokenKind ] ,
831
831
) -> bool {
832
832
closes_expected. iter ( ) . any ( |& close| self . check ( close) )
@@ -838,9 +838,9 @@ impl<'a> Parser<'a> {
838
838
/// closing bracket.
839
839
fn parse_seq_to_before_tokens < T > (
840
840
& mut self ,
841
- closes_expected : & [ ExpTokenPair < ' _ > ] ,
841
+ closes_expected : & [ ExpTokenPair ] ,
842
842
closes_not_expected : & [ & TokenKind ] ,
843
- sep : SeqSep < ' _ > ,
843
+ sep : SeqSep ,
844
844
mut f : impl FnMut ( & mut Parser < ' a > ) -> PResult < ' a , T > ,
845
845
) -> PResult < ' a , ( ThinVec < T > , Trailing , Recovered ) > {
846
846
let mut first = true ;
@@ -869,7 +869,7 @@ impl<'a> Parser<'a> {
869
869
}
870
870
Err ( mut expect_err) => {
871
871
let sp = self . prev_token . span . shrink_to_hi ( ) ;
872
- let token_str = pprust:: token_kind_to_string ( exp. tok ) ;
872
+ let token_str = pprust:: token_kind_to_string ( & exp. tok ) ;
873
873
874
874
match self . current_closure . take ( ) {
875
875
Some ( closure_spans) if self . token == TokenKind :: Semi => {
@@ -1039,8 +1039,8 @@ impl<'a> Parser<'a> {
1039
1039
/// closing bracket.
1040
1040
fn parse_seq_to_before_end < T > (
1041
1041
& mut self ,
1042
- close : ExpTokenPair < ' _ > ,
1043
- sep : SeqSep < ' _ > ,
1042
+ close : ExpTokenPair ,
1043
+ sep : SeqSep ,
1044
1044
f : impl FnMut ( & mut Parser < ' a > ) -> PResult < ' a , T > ,
1045
1045
) -> PResult < ' a , ( ThinVec < T > , Trailing , Recovered ) > {
1046
1046
self . parse_seq_to_before_tokens ( & [ close] , & [ ] , sep, f)
@@ -1051,8 +1051,8 @@ impl<'a> Parser<'a> {
1051
1051
/// closing bracket.
1052
1052
fn parse_seq_to_end < T > (
1053
1053
& mut self ,
1054
- close : ExpTokenPair < ' _ > ,
1055
- sep : SeqSep < ' _ > ,
1054
+ close : ExpTokenPair ,
1055
+ sep : SeqSep ,
1056
1056
f : impl FnMut ( & mut Parser < ' a > ) -> PResult < ' a , T > ,
1057
1057
) -> PResult < ' a , ( ThinVec < T > , Trailing ) > {
1058
1058
let ( val, trailing, recovered) = self . parse_seq_to_before_end ( close, sep, f) ?;
@@ -1070,9 +1070,9 @@ impl<'a> Parser<'a> {
1070
1070
/// closing bracket.
1071
1071
fn parse_unspanned_seq < T > (
1072
1072
& mut self ,
1073
- open : ExpTokenPair < ' _ > ,
1074
- close : ExpTokenPair < ' _ > ,
1075
- sep : SeqSep < ' _ > ,
1073
+ open : ExpTokenPair ,
1074
+ close : ExpTokenPair ,
1075
+ sep : SeqSep ,
1076
1076
f : impl FnMut ( & mut Parser < ' a > ) -> PResult < ' a , T > ,
1077
1077
) -> PResult < ' a , ( ThinVec < T > , Trailing ) > {
1078
1078
self . expect ( open) ?;
@@ -1084,8 +1084,8 @@ impl<'a> Parser<'a> {
1084
1084
/// closing bracket.
1085
1085
fn parse_delim_comma_seq < T > (
1086
1086
& mut self ,
1087
- open : ExpTokenPair < ' _ > ,
1088
- close : ExpTokenPair < ' _ > ,
1087
+ open : ExpTokenPair ,
1088
+ close : ExpTokenPair ,
1089
1089
f : impl FnMut ( & mut Parser < ' a > ) -> PResult < ' a , T > ,
1090
1090
) -> PResult < ' a , ( ThinVec < T > , Trailing ) > {
1091
1091
self . parse_unspanned_seq ( open, close, SeqSep :: trailing_allowed ( exp ! ( Comma ) ) , f)
0 commit comments