@@ -449,9 +449,13 @@ impl<'a> Parser<'a> {
449
449
prev_token_before_parsing : Token ,
450
450
error : & mut Diag < ' _ > ,
451
451
) {
452
- if ( ( style == PathStyle :: Expr && self . parse_paren_comma_seq ( |p| p. parse_expr ( ) ) . is_ok ( ) )
453
- || ( style == PathStyle :: Pat
454
- && self
452
+ match style {
453
+ PathStyle :: Expr
454
+ if let Ok ( _) = self
455
+ . parse_paren_comma_seq ( |p| p. parse_expr ( ) )
456
+ . map_err ( |error| error. cancel ( ) ) => { }
457
+ PathStyle :: Pat
458
+ if let Ok ( _) = self
455
459
. parse_paren_comma_seq ( |p| {
456
460
p. parse_pat_allow_top_alt (
457
461
None ,
@@ -460,25 +464,31 @@ impl<'a> Parser<'a> {
460
464
CommaRecoveryMode :: LikelyTuple ,
461
465
)
462
466
} )
463
- . is_ok ( ) ) )
464
- && !matches ! ( self . token. kind, token:: ModSep | token:: RArrow )
465
- {
466
- error. span_suggestion_verbose (
467
- prev_token_before_parsing. span ,
468
- format ! (
469
- "consider removing the `::` here to {}" ,
470
- match style {
471
- PathStyle :: Expr => "call the expression" ,
472
- PathStyle :: Pat => "turn this into a tuple struct pattern" ,
473
- _ => {
474
- return ;
475
- }
476
- }
477
- ) ,
478
- "" ,
479
- Applicability :: MaybeIncorrect ,
480
- ) ;
467
+ . map_err ( |error| error. cancel ( ) ) => { }
468
+ _ => {
469
+ return ;
470
+ }
481
471
}
472
+
473
+ if let token:: ModSep | token:: RArrow = self . token . kind {
474
+ return ;
475
+ }
476
+
477
+ error. span_suggestion_verbose (
478
+ prev_token_before_parsing. span ,
479
+ format ! (
480
+ "consider removing the `::` here to {}" ,
481
+ match style {
482
+ PathStyle :: Expr => "call the expression" ,
483
+ PathStyle :: Pat => "turn this into a tuple struct pattern" ,
484
+ _ => {
485
+ return ;
486
+ }
487
+ }
488
+ ) ,
489
+ "" ,
490
+ Applicability :: MaybeIncorrect ,
491
+ ) ;
482
492
}
483
493
484
494
/// Parses generic args (within a path segment) with recovery for extra leading angle brackets.
0 commit comments