Skip to content

Commit e5e3bbd

Browse files
committed
extend the let-chain
1 parent 0a2eece commit e5e3bbd

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

clippy_lints/src/replace_box.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,11 @@ impl LateLintPass<'_> for ReplaceBox {
4040
if let ExprKind::Assign(lhs, rhs, _) = &expr.kind
4141
&& !lhs.span.from_expansion()
4242
&& !rhs.span.from_expansion()
43-
{
44-
let lhs_ty = cx.typeck_results().expr_ty(lhs);
45-
43+
&& let lhs_ty = cx.typeck_results().expr_ty(lhs)
4644
// No diagnostic for late-initialized locals
47-
if let Some(local) = path_to_local(lhs)
48-
&& !local_is_initialized(cx, local)
49-
{
50-
return;
51-
}
52-
53-
let Some(inner_ty) = get_box_inner_type(cx, lhs_ty) else {
54-
return;
55-
};
56-
45+
&& path_to_local(lhs).is_none_or(|local| local_is_initialized(cx, local))
46+
&& let Some(inner_ty) = get_box_inner_type(cx, lhs_ty)
47+
{
5748
if let Some(default_trait_id) = cx.tcx.get_diagnostic_item(sym::Default)
5849
&& implements_trait(cx, inner_ty, default_trait_id, &[])
5950
&& is_default_call(cx, rhs)

0 commit comments

Comments
 (0)