Skip to content

Commit 8ba38fa

Browse files
committed
Apply minor style suggestions
1 parent 02237ff commit 8ba38fa

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

clippy_lints/src/default_box_assignments.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,8 @@ impl LateLintPass<'_> for DefaultBoxAssignments {
5151
return;
5252
};
5353

54-
let Some(default_trait_id) = cx.tcx.get_diagnostic_item(sym::Default) else {
55-
return;
56-
};
57-
58-
if implements_trait(cx, inner_ty, default_trait_id, &[])
54+
if let Some(default_trait_id) = cx.tcx.get_diagnostic_item(sym::Default)
55+
&& implements_trait(cx, inner_ty, default_trait_id, &[])
5956
&& is_default_call(cx, rhs)
6057
&& !rhs.span.from_expansion()
6158
{
@@ -82,7 +79,7 @@ impl LateLintPass<'_> for DefaultBoxAssignments {
8279
}
8380

8481
if inner_ty.is_sized(cx.tcx, cx.typing_env())
85-
&& let Some(rhs_inner) = get_new_call_value(cx, rhs)
82+
&& let Some(rhs_inner) = get_box_new_payload(cx, rhs)
8683
{
8784
span_lint_and_then(cx, DEFAULT_BOX_ASSIGNMENTS, expr.span, "creating a new box", |diag| {
8885
let mut app = Applicability::MachineApplicable;
@@ -118,7 +115,7 @@ fn is_default_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
118115
matches!(expr.kind, ExprKind::Call(func, _args) if is_default_equivalent_call(cx, func, Some(expr)))
119116
}
120117

121-
fn get_new_call_value<'tcx>(cx: &LateContext<'_>, expr: &Expr<'tcx>) -> Option<&'tcx Expr<'tcx>> {
118+
fn get_box_new_payload<'tcx>(cx: &LateContext<'_>, expr: &Expr<'tcx>) -> Option<&'tcx Expr<'tcx>> {
122119
if let ExprKind::Call(box_new, [arg]) = expr.kind
123120
&& let ExprKind::Path(QPath::TypeRelative(ty, seg)) = box_new.kind
124121
&& seg.ident.name == sym::new

0 commit comments

Comments
 (0)