@@ -2341,16 +2341,9 @@ impl<'a> Parser<'a> {
2341
2341
2342
2342
/// Parses the condition of a `if` or `while` expression.
2343
2343
fn parse_cond_expr ( & mut self ) -> PResult < ' a , P < Expr > > {
2344
- let cond = self . with_let_management ( true , |local_self| {
2344
+ self . with_let_management ( true , |local_self| {
2345
2345
local_self. parse_expr_res ( Restrictions :: NO_STRUCT_LITERAL , None )
2346
- } ) ?;
2347
-
2348
- if let ExprKind :: Let ( ..) = cond. kind {
2349
- // Remove the last feature gating of a `let` expression since it's stable.
2350
- self . sess . gated_spans . ungate_last ( sym:: let_chains, cond. span ) ;
2351
- }
2352
-
2353
- Ok ( cond)
2346
+ } )
2354
2347
}
2355
2348
2356
2349
// Checks if `let` is in an invalid position like `let x = let y = 1;` or
@@ -2389,7 +2382,6 @@ impl<'a> Parser<'a> {
2389
2382
this. parse_assoc_expr_with ( 1 + prec_let_scrutinee_needs_par ( ) , None . into ( ) )
2390
2383
} ) ?;
2391
2384
let span = lo. to ( expr. span ) ;
2392
- self . sess . gated_spans . gate ( sym:: let_chains, span) ;
2393
2385
Ok ( self . mk_expr ( span, ExprKind :: Let ( pat, expr, span) , attrs) )
2394
2386
}
2395
2387
@@ -2695,15 +2687,11 @@ impl<'a> Parser<'a> {
2695
2687
pub ( super ) fn parse_arm ( & mut self ) -> PResult < ' a , Arm > {
2696
2688
// Used to check the `let_chains` and `if_let_guard` features mostly by scaning
2697
2689
// `&&` tokens.
2698
- fn check_let_expr ( expr : & Expr ) -> ( bool , bool ) {
2690
+ fn check_let_expr ( expr : & Expr ) -> bool {
2699
2691
match expr. kind {
2700
- ExprKind :: Binary ( _, ref lhs, ref rhs) => {
2701
- let lhs_rslt = check_let_expr ( lhs) ;
2702
- let rhs_rslt = check_let_expr ( rhs) ;
2703
- ( lhs_rslt. 0 || rhs_rslt. 0 , false )
2704
- }
2705
- ExprKind :: Let ( ..) => ( true , true ) ,
2706
- _ => ( false , true ) ,
2692
+ ExprKind :: Binary ( _, ref lhs, ref rhs) => check_let_expr ( lhs) || check_let_expr ( rhs) ,
2693
+ ExprKind :: Let ( ..) => true ,
2694
+ _ => false ,
2707
2695
}
2708
2696
}
2709
2697
let attrs = self . parse_outer_attributes ( ) ?;
@@ -2718,12 +2706,8 @@ impl<'a> Parser<'a> {
2718
2706
let guard = if this. eat_keyword ( kw:: If ) {
2719
2707
let if_span = this. prev_token . span ;
2720
2708
let cond = this. with_let_management ( true , |local_this| local_this. parse_expr ( ) ) ?;
2721
- let ( has_let_expr, does_not_have_bin_op ) = check_let_expr ( & cond) ;
2709
+ let has_let_expr = check_let_expr ( & cond) ;
2722
2710
if has_let_expr {
2723
- if does_not_have_bin_op {
2724
- // Remove the last feature gating of a `let` expression since it's stable.
2725
- this. sess . gated_spans . ungate_last ( sym:: let_chains, cond. span ) ;
2726
- }
2727
2711
let span = if_span. to ( cond. span ) ;
2728
2712
this. sess . gated_spans . gate ( sym:: if_let_guard, span) ;
2729
2713
}
0 commit comments