Skip to content

Commit 4b19a31

Browse files
committed
add itermediate variables for more legibility
1 parent eb20630 commit 4b19a31

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

clippy_lints/src/equatable_if_let.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,17 @@ 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-
|| (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+
let eq_method_is_const = || {
74+
self.eq_method
75+
.is_some_and(|eq_method| is_stable_const_fn(cx, eq_method, self.msrv))
76+
};
77+
78+
is_partial_eq() && (!is_in_const_context(cx) || eq_method_is_const())
7179
}
7280
}
7381

0 commit comments

Comments
 (0)