From b011a0a13b4354080b3add0bb3f4445ddb8fd13b Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Mon, 11 Sep 2023 16:16:59 +0000 Subject: 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. --- compiler/rustc_parse/src/parser/expr.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_parse') 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, .. }, _, _) => { -- cgit 1.4.1-3-g733a5