Skip to content

Commit aca4086

Browse files
committed
simplify matching on binop result
1 parent 7696c9d commit aca4086

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

clippy_utils/src/eager_or_lazy.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,17 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS
229229

230230
ExprKind::Binary(op, left, right)
231231
if matches!(op.node, BinOpKind::Div | BinOpKind::Rem)
232-
&& let left_ty = self.cx.typeck_results().expr_ty(left)
233232
&& let right_ty = self.cx.typeck_results().expr_ty(right)
234233
&& let left = constant(self.cx, self.cx.typeck_results(), left)
235-
.and_then(|c| c.int_value(self.cx, left_ty))
236234
&& let right = constant(self.cx, self.cx.typeck_results(), right)
237235
.and_then(|c| c.int_value(self.cx, right_ty))
238-
&& match (left, right) {
239-
// `1 / x` -- x might be zero
240-
(_, None) => true,
241-
// `x / -1` -- x might be T::MIN = panic
242-
#[expect(clippy::match_same_arms)]
243-
(None, Some(FullInt::S(-1))) => true,
244-
// anything else is either fine or checked by the compiler
245-
_ => false,
246-
} =>
236+
&& matches!(
237+
(left, right),
238+
// `1 / x`: x might be zero
239+
(_, None)
240+
// `x / -1`: x might be T::MIN
241+
| (None, Some(FullInt::S(-1)))
242+
) =>
247243
{
248244
self.eagerness |= NoChange;
249245
},

0 commit comments

Comments
 (0)