@@ -51,11 +51,8 @@ impl LateLintPass<'_> for DefaultBoxAssignments {
51
51
return ;
52
52
} ;
53
53
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, & [ ] )
59
56
&& is_default_call ( cx, rhs)
60
57
&& !rhs. span . from_expansion ( )
61
58
{
@@ -82,7 +79,7 @@ impl LateLintPass<'_> for DefaultBoxAssignments {
82
79
}
83
80
84
81
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)
86
83
{
87
84
span_lint_and_then ( cx, DEFAULT_BOX_ASSIGNMENTS , expr. span , "creating a new box" , |diag| {
88
85
let mut app = Applicability :: MachineApplicable ;
@@ -118,7 +115,7 @@ fn is_default_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
118
115
matches ! ( expr. kind, ExprKind :: Call ( func, _args) if is_default_equivalent_call( cx, func, Some ( expr) ) )
119
116
}
120
117
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 > > {
122
119
if let ExprKind :: Call ( box_new, [ arg] ) = expr. kind
123
120
&& let ExprKind :: Path ( QPath :: TypeRelative ( ty, seg) ) = box_new. kind
124
121
&& seg. ident . name == sym:: new
0 commit comments