Skip to content

Commit 96838e2

Browse files
committed
add itermediate variables for more legibility
1 parent 6d2afa1 commit 96838e2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

clippy_lints/src/equatable_if_let.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,18 @@ impl PatternEquality {
6565
}
6666

6767
fn is_structural_partial_eq<'tcx>(&self, cx: &LateContext<'tcx>, ty: Ty<'tcx>, other: Ty<'tcx>) -> bool {
68-
(self.eq_trait).is_some_and(|eq_trait| implements_trait(cx, ty, eq_trait, &[other.into()]))
69-
&& (!is_in_const_context(cx)
70-
// TODO: add a MSRV test once `eq` becomes stably-const
71-
|| (self.eq_method).is_some_and(|eq_method| is_stable_const_fn(cx, eq_method, self.msrv)))
68+
let is_partial_eq = || {
69+
self.eq_trait
70+
.is_some_and(|eq_trait| implements_trait(cx, ty, eq_trait, &[other.into()]))
71+
};
72+
73+
// TODO: add a MSRV test once `eq` becomes stably-const
74+
let eq_method_is_const = || {
75+
self.eq_method
76+
.is_some_and(|eq_method| is_stable_const_fn(cx, eq_method, self.msrv))
77+
};
78+
79+
is_partial_eq() && (!is_in_const_context(cx) || eq_method_is_const())
7280
}
7381
}
7482

0 commit comments

Comments
 (0)