diff options
| author | bors <bors@rust-lang.org> | 2022-01-23 23:09:23 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-01-23 23:09:23 +0000 |
| commit | 42313dd29b3edb0ab453a0d43d12876ec7e48ce0 (patch) | |
| tree | 94efb537a260c94c6fcd5f45d2583dc8cad8e719 /compiler/rustc_parse/src/parser | |
| parent | 84322efad553c7a79c80189f2d1b9197c1aa005f (diff) | |
| parent | eea833f5f1d0de940c0759cc365cef7624a732df (diff) | |
| download | rust-42313dd29b3edb0ab453a0d43d12876ec7e48ce0.tar.gz rust-42313dd29b3edb0ab453a0d43d12876ec7e48ce0.zip | |
Auto merge of #93245 - matthiaskrgr:rollup-djsi6jr, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #91526 (rustc_lint: Some early linting refactorings) - #92555 (Implement RFC 3151: Scoped threads.) - #93213 (Fix `let_chains` and `if_let_guard` feature flags) - #93219 (Add preliminary support for inline assembly for msp430.) - #93226 (Normalize field access types during borrowck) - #93227 (Liberate late bound regions when collecting GAT substs in wfcheck) - #93229 (Remove DiagnosticBuilder.quiet) - #93234 (rustc_mir_itertools: Avoid needless `collect` with itertools) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 192e87b4c01..26284728ff2 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2383,6 +2383,17 @@ impl<'a> Parser<'a> { } pub(super) fn parse_arm(&mut self) -> PResult<'a, Arm> { + fn check_let_expr(expr: &Expr) -> (bool, 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), + } + } let attrs = self.parse_outer_attributes()?; self.collect_tokens_trailing_token(attrs, ForceCollect::No, |this, attrs| { let lo = this.token.span; @@ -2390,9 +2401,12 @@ impl<'a> Parser<'a> { let guard = if this.eat_keyword(kw::If) { let if_span = this.prev_token.span; let cond = this.parse_expr()?; - if let ExprKind::Let(..) = cond.kind { - // 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 (has_let_expr, does_not_have_bin_op) = 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); } |
