about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorCaio <c410.f3r@gmail.com>2022-07-12 15:36:59 -0300
committerCaio <c410.f3r@gmail.com>2022-07-16 20:17:58 -0300
commit326646074940222d602f3683d0559088690830f4 (patch)
tree55297110643d94c0f780cc0e3bcae2e7e20dd54b /compiler/rustc_parse/src/parser
parentd5e7f4782e4b699728d0a08200ecd1a54d56a85d (diff)
downloadrust-326646074940222d602f3683d0559088690830f4.tar.gz
rust-326646074940222d602f3683d0559088690830f4.zip
Stabilize `let_chains`
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs30
1 files changed, 7 insertions, 23 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index 478d5e4792a..8e1b279d9b6 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -2341,16 +2341,9 @@ impl<'a> Parser<'a> {
 
     /// Parses the condition of a `if` or `while` expression.
     fn parse_cond_expr(&mut self) -> PResult<'a, P<Expr>> {
-        let cond = self.with_let_management(true, |local_self| {
+        self.with_let_management(true, |local_self| {
             local_self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)
-        })?;
-
-        if let ExprKind::Let(..) = cond.kind {
-            // Remove the last feature gating of a `let` expression since it's stable.
-            self.sess.gated_spans.ungate_last(sym::let_chains, cond.span);
-        }
-
-        Ok(cond)
+        })
     }
 
     // Checks if `let` is in an invalid position like `let x = let y = 1;` or
@@ -2389,7 +2382,6 @@ impl<'a> Parser<'a> {
             this.parse_assoc_expr_with(1 + prec_let_scrutinee_needs_par(), None.into())
         })?;
         let span = lo.to(expr.span);
-        self.sess.gated_spans.gate(sym::let_chains, span);
         Ok(self.mk_expr(span, ExprKind::Let(pat, expr, span), attrs))
     }
 
@@ -2695,15 +2687,11 @@ impl<'a> Parser<'a> {
     pub(super) fn parse_arm(&mut self) -> PResult<'a, Arm> {
         // Used to check the `let_chains` and `if_let_guard` features mostly by scaning
         // `&&` tokens.
-        fn check_let_expr(expr: &Expr) -> (bool, bool) {
+        fn check_let_expr(expr: &Expr) -> bool {
             match expr.kind {
-                ExprKind::Binary(_, ref lhs, ref rhs) => {
-                    let lhs_rslt = check_let_expr(lhs);
-                    let rhs_rslt = check_let_expr(rhs);
-                    (lhs_rslt.0 || rhs_rslt.0, false)
-                }
-                ExprKind::Let(..) => (true, true),
-                _ => (false, true),
+                ExprKind::Binary(_, ref lhs, ref rhs) => check_let_expr(lhs) || check_let_expr(rhs),
+                ExprKind::Let(..) => true,
+                _ => false,
             }
         }
         let attrs = self.parse_outer_attributes()?;
@@ -2718,12 +2706,8 @@ impl<'a> Parser<'a> {
             let guard = if this.eat_keyword(kw::If) {
                 let if_span = this.prev_token.span;
                 let cond = this.with_let_management(true, |local_this| local_this.parse_expr())?;
-                let (has_let_expr, does_not_have_bin_op) = check_let_expr(&cond);
+                let has_let_expr = check_let_expr(&cond);
                 if has_let_expr {
-                    if does_not_have_bin_op {
-                        // Remove the last feature gating of a `let` expression since it's stable.
-                        this.sess.gated_spans.ungate_last(sym::let_chains, cond.span);
-                    }
                     let span = if_span.to(cond.span);
                     this.sess.gated_spans.gate(sym::if_let_guard, span);
                 }