about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-14 06:46:16 +0000
committerbors <bors@rust-lang.org>2024-03-14 06:46:16 +0000
commit24071bdf889d89052efcb3245c6de90a8899526e (patch)
treeeec550e91293d7ce0f751cfad6e41493186a515c /compiler/rustc_parse/src/parser
parent34d6f07646e28977a2b7fb5c90202b6973c4441e (diff)
parent4cd673b4c6b6c633ea768b7d5ff1dbfead53c153 (diff)
downloadrust-24071bdf889d89052efcb3245c6de90a8899526e.tar.gz
rust-24071bdf889d89052efcb3245c6de90a8899526e.zip
Auto merge of #3378 - rust-lang:rustup-2024-03-14, r=RalfJung
Automatic Rustup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/path.rs52
-rw-r--r--compiler/rustc_parse/src/parser/stmt.rs8
2 files changed, 35 insertions, 25 deletions
diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs
index 2edf2111de7..163d10d03f0 100644
--- a/compiler/rustc_parse/src/parser/path.rs
+++ b/compiler/rustc_parse/src/parser/path.rs
@@ -449,9 +449,13 @@ impl<'a> Parser<'a> {
         prev_token_before_parsing: Token,
         error: &mut Diag<'_>,
     ) {
-        if ((style == PathStyle::Expr && self.parse_paren_comma_seq(|p| p.parse_expr()).is_ok())
-            || (style == PathStyle::Pat
-                && self
+        match style {
+            PathStyle::Expr
+                if let Ok(_) = self
+                    .parse_paren_comma_seq(|p| p.parse_expr())
+                    .map_err(|error| error.cancel()) => {}
+            PathStyle::Pat
+                if let Ok(_) = self
                     .parse_paren_comma_seq(|p| {
                         p.parse_pat_allow_top_alt(
                             None,
@@ -460,25 +464,31 @@ impl<'a> Parser<'a> {
                             CommaRecoveryMode::LikelyTuple,
                         )
                     })
-                    .is_ok()))
-            && !matches!(self.token.kind, token::ModSep | token::RArrow)
-        {
-            error.span_suggestion_verbose(
-                prev_token_before_parsing.span,
-                format!(
-                    "consider removing the `::` here to {}",
-                    match style {
-                        PathStyle::Expr => "call the expression",
-                        PathStyle::Pat => "turn this into a tuple struct pattern",
-                        _ => {
-                            return;
-                        }
-                    }
-                ),
-                "",
-                Applicability::MaybeIncorrect,
-            );
+                    .map_err(|error| error.cancel()) => {}
+            _ => {
+                return;
+            }
         }
+
+        if let token::ModSep | token::RArrow = self.token.kind {
+            return;
+        }
+
+        error.span_suggestion_verbose(
+            prev_token_before_parsing.span,
+            format!(
+                "consider removing the `::` here to {}",
+                match style {
+                    PathStyle::Expr => "call the expression",
+                    PathStyle::Pat => "turn this into a tuple struct pattern",
+                    _ => {
+                        return;
+                    }
+                }
+            ),
+            "",
+            Applicability::MaybeIncorrect,
+        );
     }
 
     /// Parses generic args (within a path segment) with recovery for extra leading angle brackets.
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs
index 73f5829adec..fc907760531 100644
--- a/compiler/rustc_parse/src/parser/stmt.rs
+++ b/compiler/rustc_parse/src/parser/stmt.rs
@@ -254,7 +254,7 @@ impl<'a> Parser<'a> {
                 let local = this.parse_local(attrs)?;
                 // FIXME - maybe capture semicolon in recovery?
                 Ok((
-                    this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Local(local)),
+                    this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Let(local)),
                     TrailingToken::None,
                 ))
             })?;
@@ -278,7 +278,7 @@ impl<'a> Parser<'a> {
             } else {
                 TrailingToken::None
             };
-            Ok((this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Local(local)), trailing))
+            Ok((this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Let(local)), trailing))
         })
     }
 
@@ -764,7 +764,7 @@ impl<'a> Parser<'a> {
                 }
             }
             StmtKind::Expr(_) | StmtKind::MacCall(_) => {}
-            StmtKind::Local(local) if let Err(mut e) = self.expect_semi() => {
+            StmtKind::Let(local) if let Err(mut e) = self.expect_semi() => {
                 // We might be at the `,` in `let x = foo<bar, baz>;`. Try to recover.
                 match &mut local.kind {
                     LocalKind::Init(expr) | LocalKind::InitElse(expr, _) => {
@@ -820,7 +820,7 @@ impl<'a> Parser<'a> {
                 }
                 eat_semi = false;
             }
-            StmtKind::Empty | StmtKind::Item(_) | StmtKind::Local(_) | StmtKind::Semi(_) => {
+            StmtKind::Empty | StmtKind::Item(_) | StmtKind::Let(_) | StmtKind::Semi(_) => {
                 eat_semi = false
             }
         }