From e5e3bbd9a1fdf989023da5e8d37190beb987662a Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Tue, 7 Oct 2025 18:23:58 +0200 Subject: [PATCH] extend the let-chain --- clippy_lints/src/replace_box.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/clippy_lints/src/replace_box.rs b/clippy_lints/src/replace_box.rs index 9388f77a839d..457c9a52a857 100644 --- a/clippy_lints/src/replace_box.rs +++ b/clippy_lints/src/replace_box.rs @@ -40,20 +40,11 @@ impl LateLintPass<'_> for ReplaceBox { if let ExprKind::Assign(lhs, rhs, _) = &expr.kind && !lhs.span.from_expansion() && !rhs.span.from_expansion() - { - let lhs_ty = cx.typeck_results().expr_ty(lhs); - + && let lhs_ty = cx.typeck_results().expr_ty(lhs) // No diagnostic for late-initialized locals - if let Some(local) = path_to_local(lhs) - && !local_is_initialized(cx, local) - { - return; - } - - let Some(inner_ty) = get_box_inner_type(cx, lhs_ty) else { - return; - }; - + && path_to_local(lhs).is_none_or(|local| local_is_initialized(cx, local)) + && let Some(inner_ty) = get_box_inner_type(cx, lhs_ty) + { if let Some(default_trait_id) = cx.tcx.get_diagnostic_item(sym::Default) && implements_trait(cx, inner_ty, default_trait_id, &[]) && is_default_call(cx, rhs)