Skip to content

Commit 9756a13

Browse files
committed
Auto merge of rust-lang#115677 - matthewjasper:let-expr-recovery, r=b-naber
Improve invalid let expression handling - Move all of the checks for valid let expression positions to parsing. - Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location. - Suppress some later errors and MIR construction for invalid let expressions. - Fix a (drop) scope issue that was also responsible for rust-lang#104172. Fixes rust-lang#104172 Fixes rust-lang#104868
2 parents eb545d7 + ab08a3d commit 9756a13

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

clippy_lints/src/suspicious_operation_groupings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ fn ident_difference_expr_with_base_location(
586586
| (ForLoop(_, _, _, _), ForLoop(_, _, _, _))
587587
| (While(_, _, _), While(_, _, _))
588588
| (If(_, _, _), If(_, _, _))
589-
| (Let(_, _, _), Let(_, _, _))
589+
| (Let(_, _, _, _), Let(_, _, _, _))
590590
| (Type(_, _), Type(_, _))
591591
| (Cast(_, _), Cast(_, _))
592592
| (Lit(_), Lit(_))

clippy_lints/src/unnested_or_patterns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl EarlyLintPass for UnnestedOrPatterns {
6868

6969
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
7070
if self.msrv.meets(msrvs::OR_PATTERNS) {
71-
if let ast::ExprKind::Let(pat, _, _) = &e.kind {
71+
if let ast::ExprKind::Let(pat, _, _, _) = &e.kind {
7272
lint_unnested_or_patterns(cx, pat);
7373
}
7474
}

clippy_utils/src/ast_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
166166
(Unary(lo, l), Unary(ro, r)) => mem::discriminant(lo) == mem::discriminant(ro) && eq_expr(l, r),
167167
(Lit(l), Lit(r)) => l == r,
168168
(Cast(l, lt), Cast(r, rt)) | (Type(l, lt), Type(r, rt)) => eq_expr(l, r) && eq_ty(lt, rt),
169-
(Let(lp, le, _), Let(rp, re, _)) => eq_pat(lp, rp) && eq_expr(le, re),
169+
(Let(lp, le, _, _), Let(rp, re, _, _)) => eq_pat(lp, rp) && eq_expr(le, re),
170170
(If(lc, lt, le), If(rc, rt, re)) => eq_expr(lc, rc) && eq_block(lt, rt) && eq_expr_opt(le, re),
171171
(While(lc, lt, ll), While(rc, rt, rl)) => eq_label(ll, rl) && eq_expr(lc, rc) && eq_block(lt, rt),
172172
(ForLoop(lp, li, lt, ll), ForLoop(rp, ri, rt, rl)) => {

0 commit comments

Comments
 (0)