about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2023-09-11 16:16:59 +0000
committerMatthew Jasper <mjjasper1@gmail.com>2023-09-11 16:17:06 +0000
commitb011a0a13b4354080b3add0bb3f4445ddb8fd13b (patch)
treea8656d9ee147bfb4480dcde68e0d21bb808a9b7c /compiler/rustc_parse/src
parent2d7a5f528c255b8018c5b4b5541fd79572dbd0c1 (diff)
downloadrust-b011a0a13b4354080b3add0bb3f4445ddb8fd13b.tar.gz
rust-b011a0a13b4354080b3add0bb3f4445ddb8fd13b.zip
Reduce double errors for invalid let expressions
Previously some invalid let expressions would result in both a feature
error and a parsing error. Avoid this and ensure that we only emit the
parsing error when this happens.
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index 82701a8b5d5..43cd8fe55df 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -2485,9 +2485,6 @@ impl<'a> Parser<'a> {
         }
         let expr = self.parse_expr_assoc_with(1 + prec_let_scrutinee_needs_par(), None.into())?;
         let span = lo.to(expr.span);
-        if is_recovered.is_none() {
-            self.sess.gated_spans.gate(sym::let_chains, span);
-        }
         Ok(self.mk_expr(span, ExprKind::Let(pat, expr, span, is_recovered)))
     }
 
@@ -3460,6 +3457,8 @@ impl MutVisitor for CondChecker<'_> {
                             .sess
                             .emit_err(errors::ExpectedExpressionFoundLet { span, reason }),
                     );
+                } else {
+                    self.parser.sess.gated_spans.gate(sym::let_chains, span);
                 }
             }
             ExprKind::Binary(Spanned { node: BinOpKind::And, .. }, _, _) => {