@@ -474,8 +474,8 @@ impl<'a> Parser<'a> {
474474 // If this isn't the case however, and the suggestion is a token the
475475 // content of which is the same as the found token's, we remove it as well.
476476 if !eq {
477- if let TokenType :: Token ( kind) = & token {
478- if kind == & self . token . kind {
477+ if let TokenType :: Token ( kind) = token {
478+ if self . token == * kind {
479479 return false ;
480480 }
481481 }
@@ -506,7 +506,7 @@ impl<'a> Parser<'a> {
506506 } else if !sm. is_multiline ( self . prev_token . span . until ( self . token . span ) ) {
507507 // The current token is in the same line as the prior token, not recoverable.
508508 } else if [ token:: Comma , token:: Colon ] . contains ( & self . token . kind )
509- && self . prev_token . kind == token:: CloseDelim ( Delimiter :: Parenthesis )
509+ && self . prev_token == token:: CloseDelim ( Delimiter :: Parenthesis )
510510 {
511511 // Likely typo: The current token is on a new line and is expected to be
512512 // `.`, `;`, `?`, or an operator after a close delimiter token.
@@ -518,7 +518,7 @@ impl<'a> Parser<'a> {
518518 // https://github.com/rust-lang/rust/issues/72253
519519 } else if self . look_ahead ( 1 , |t| {
520520 t == & token:: CloseDelim ( Delimiter :: Brace )
521- || t. can_begin_expr ( ) && t . kind != token:: Colon
521+ || t. can_begin_expr ( ) && * t != token:: Colon
522522 } ) && [ token:: Comma , token:: Colon ] . contains ( & self . token . kind )
523523 {
524524 // Likely typo: `,` → `;` or `:` → `;`. This is triggered if the current token is
@@ -562,7 +562,7 @@ impl<'a> Parser<'a> {
562562 }
563563 }
564564
565- if self . token . kind == TokenKind :: EqEq
565+ if self . token == TokenKind :: EqEq
566566 && self . prev_token . is_ident ( )
567567 && expected. iter ( ) . any ( |tok| matches ! ( tok, TokenType :: Token ( TokenKind :: Eq ) ) )
568568 {
@@ -655,9 +655,9 @@ impl<'a> Parser<'a> {
655655 // positive for a `cr#` that wasn't intended to start a c-string literal, but identifying
656656 // that in the parser requires unbounded lookahead, so we only add a hint to the existing
657657 // error rather than replacing it entirely.
658- if ( ( self . prev_token . kind == TokenKind :: Ident ( sym:: c, IdentIsRaw :: No )
658+ if ( ( self . prev_token == TokenKind :: Ident ( sym:: c, IdentIsRaw :: No )
659659 && matches ! ( & self . token. kind, TokenKind :: Literal ( token:: Lit { kind: token:: Str , .. } ) ) )
660- || ( self . prev_token . kind == TokenKind :: Ident ( sym:: cr, IdentIsRaw :: No )
660+ || ( self . prev_token == TokenKind :: Ident ( sym:: cr, IdentIsRaw :: No )
661661 && matches ! (
662662 & self . token. kind,
663663 TokenKind :: Literal ( token:: Lit { kind: token:: Str , .. } ) | token:: Pound
@@ -673,7 +673,7 @@ impl<'a> Parser<'a> {
673673 // `pub` may be used for an item or `pub(crate)`
674674 if self . prev_token . is_ident_named ( sym:: public)
675675 && ( self . token . can_begin_item ( )
676- || self . token . kind == TokenKind :: OpenDelim ( Delimiter :: Parenthesis ) )
676+ || self . token == TokenKind :: OpenDelim ( Delimiter :: Parenthesis ) )
677677 {
678678 err. span_suggestion_short (
679679 self . prev_token . span ,
@@ -772,7 +772,7 @@ impl<'a> Parser<'a> {
772772 ) ,
773773 ) ;
774774 if self . token == token:: Pound
775- && self . look_ahead ( 1 , |t| t . kind == token:: OpenDelim ( Delimiter :: Bracket ) )
775+ && self . look_ahead ( 1 , |t| * t == token:: OpenDelim ( Delimiter :: Bracket ) )
776776 {
777777 // We have
778778 // #[attr]
@@ -867,7 +867,7 @@ impl<'a> Parser<'a> {
867867 let str_span = self . prev_token . span ;
868868 let mut span = self . token . span ;
869869 let mut count = 0 ;
870- while self . token . kind == TokenKind :: Pound
870+ while self . token == TokenKind :: Pound
871871 && !sm. is_multiline ( span. shrink_to_hi ( ) . until ( self . token . span . shrink_to_lo ( ) ) )
872872 {
873873 span = span. with_hi ( self . token . span . hi ( ) ) ;
@@ -1167,7 +1167,7 @@ impl<'a> Parser<'a> {
11671167 return ;
11681168 }
11691169
1170- if token:: PathSep == self . token . kind && segment. args . is_none ( ) {
1170+ if self . token == token:: PathSep && segment. args . is_none ( ) {
11711171 let snapshot = self . create_snapshot_for_diagnostic ( ) ;
11721172 self . bump ( ) ;
11731173 let lo = self . token . span ;
@@ -1176,13 +1176,11 @@ impl<'a> Parser<'a> {
11761176 let span = lo. to ( self . prev_token . span ) ;
11771177 // Detect trailing `>` like in `x.collect::Vec<_>>()`.
11781178 let mut trailing_span = self . prev_token . span . shrink_to_hi ( ) ;
1179- while self . token . kind == token:: BinOp ( token:: Shr )
1180- || self . token . kind == token:: Gt
1181- {
1179+ while self . token == token:: BinOp ( token:: Shr ) || self . token == token:: Gt {
11821180 trailing_span = trailing_span. to ( self . token . span ) ;
11831181 self . bump ( ) ;
11841182 }
1185- if self . token . kind == token:: OpenDelim ( Delimiter :: Parenthesis ) {
1183+ if self . token == token:: OpenDelim ( Delimiter :: Parenthesis ) {
11861184 // Recover from bad turbofish: `foo.collect::Vec<_>()`.
11871185 segment. args = Some ( AngleBracketedArgs { args, span } . into ( ) ) ;
11881186
@@ -1430,7 +1428,7 @@ impl<'a> Parser<'a> {
14301428 self . restore_snapshot ( snapshot) ;
14311429 }
14321430 }
1433- return if token:: PathSep == self . token . kind {
1431+ return if self . token == token:: PathSep {
14341432 // We have some certainty that this was a bad turbofish at this point.
14351433 // `foo< bar >::`
14361434 if let ExprKind :: Binary ( o, ..) = inner_op. kind
@@ -1462,7 +1460,7 @@ impl<'a> Parser<'a> {
14621460 Err ( self . dcx ( ) . create_err ( err) )
14631461 }
14641462 }
1465- } else if token:: OpenDelim ( Delimiter :: Parenthesis ) == self . token . kind {
1463+ } else if self . token == token :: OpenDelim ( Delimiter :: Parenthesis ) {
14661464 // We have high certainty that this was a bad turbofish at this point.
14671465 // `foo< bar >(`
14681466 if let ExprKind :: Binary ( o, ..) = inner_op. kind
@@ -1528,7 +1526,7 @@ impl<'a> Parser<'a> {
15281526 ] ;
15291527 self . consume_tts ( 1 , & modifiers) ;
15301528
1531- if self . token . kind == token:: Eof {
1529+ if self . token == token:: Eof {
15321530 // Not entirely sure that what we consumed were fn arguments, rollback.
15331531 self . restore_snapshot ( snapshot) ;
15341532 Err ( ( ) )
@@ -1811,7 +1809,7 @@ impl<'a> Parser<'a> {
18111809 /// This function gets called in places where a semicolon is NOT expected and if there's a
18121810 /// semicolon it emits the appropriate error and returns true.
18131811 pub fn maybe_consume_incorrect_semicolon ( & mut self , previous_item : Option < & Item > ) -> bool {
1814- if self . token . kind != TokenKind :: Semi {
1812+ if self . token != TokenKind :: Semi {
18151813 return false ;
18161814 }
18171815
@@ -2405,10 +2403,10 @@ impl<'a> Parser<'a> {
24052403 modifier : & [ ( token:: TokenKind , i64 ) ] ,
24062404 ) {
24072405 while acc > 0 {
2408- if let Some ( ( _, val) ) = modifier. iter ( ) . find ( |( t, _) | * t == self . token . kind ) {
2406+ if let Some ( ( _, val) ) = modifier. iter ( ) . find ( |( t, _) | self . token == * t ) {
24092407 acc += * val;
24102408 }
2411- if self . token . kind == token:: Eof {
2409+ if self . token == token:: Eof {
24122410 break ;
24132411 }
24142412 self . bump ( ) ;
@@ -2598,7 +2596,7 @@ impl<'a> Parser<'a> {
25982596 }
25992597 } )
26002598 . is_some ( )
2601- || self . token . kind == TokenKind :: Dot ;
2599+ || self . token == TokenKind :: Dot ;
26022600 // This will be true when a trait object type `Foo +` or a path which was a `const fn` with
26032601 // type params has been parsed.
26042602 let was_op =
@@ -2617,7 +2615,7 @@ impl<'a> Parser<'a> {
26172615 } ) ( ) {
26182616 Ok ( expr) => {
26192617 // Find a mistake like `MyTrait<Assoc == S::Assoc>`.
2620- if token:: EqEq == snapshot . token . kind {
2618+ if snapshot . token == token:: EqEq {
26212619 err. span_suggestion (
26222620 snapshot. token . span ,
26232621 "if you meant to use an associated type binding, replace `==` with `=`" ,
@@ -2627,7 +2625,7 @@ impl<'a> Parser<'a> {
26272625 let guar = err. emit ( ) ;
26282626 let value = self . mk_expr_err ( start. to ( expr. span ) , guar) ;
26292627 return Ok ( GenericArg :: Const ( AnonConst { id : ast:: DUMMY_NODE_ID , value } ) ) ;
2630- } else if token:: Colon == snapshot . token . kind
2628+ } else if snapshot . token == token:: Colon
26312629 && expr. span . lo ( ) == snapshot. token . span . hi ( )
26322630 && matches ! ( expr. kind, ExprKind :: Path ( ..) )
26332631 {
@@ -2642,8 +2640,7 @@ impl<'a> Parser<'a> {
26422640 return Ok ( GenericArg :: Type (
26432641 self . mk_ty ( start. to ( expr. span ) , TyKind :: Err ( guar) ) ,
26442642 ) ) ;
2645- } else if token:: Comma == self . token . kind || self . token . kind . should_end_const_arg ( )
2646- {
2643+ } else if self . token == token:: Comma || self . token . kind . should_end_const_arg ( ) {
26472644 // Avoid the following output by checking that we consumed a full const arg:
26482645 // help: expressions must be enclosed in braces to be used as const generic
26492646 // arguments
@@ -2846,8 +2843,8 @@ impl<'a> Parser<'a> {
28462843 pub ( crate ) fn maybe_recover_unexpected_block_label ( & mut self ) -> bool {
28472844 // Check for `'a : {`
28482845 if !( self . check_lifetime ( )
2849- && self . look_ahead ( 1 , |tok| tok . kind == token:: Colon )
2850- && self . look_ahead ( 2 , |tok| tok . kind == token:: OpenDelim ( Delimiter :: Brace ) ) )
2846+ && self . look_ahead ( 1 , |t| * t == token:: Colon )
2847+ && self . look_ahead ( 2 , |t| * t == token:: OpenDelim ( Delimiter :: Brace ) ) )
28512848 {
28522849 return false ;
28532850 }
@@ -3001,7 +2998,7 @@ impl<'a> Parser<'a> {
30012998 // >>>>>>>
30022999 let mut end = None ;
30033000 loop {
3004- if self . token . kind == TokenKind :: Eof {
3001+ if self . token == TokenKind :: Eof {
30053002 break ;
30063003 }
30073004 if let Some ( span) = self . conflict_marker ( & TokenKind :: OrOr , & TokenKind :: BinOp ( token:: Or ) )
0 commit comments