Skip to content

Commit 2cc6cb1

Browse files
committed
Cleaned implements_ord helper function in boolean lint file.
1 parent e90a4d8 commit 2cc6cb1

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

clippy_lints/src/booleans.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,9 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
123123
let negated = match e.node {
124124
ExprBinary(binop, ref lhs, ref rhs) => {
125125

126-
match implements_ord(self.cx, lhs) {
127-
Some(true) => (),
128-
_ => continue,
129-
};
126+
if !implements_ord(self.cx, lhs) {
127+
continue;
128+
}
130129

131130
let mk_expr = |op| {
132131
Expr {
@@ -181,10 +180,9 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
181180
match expr.node {
182181
ExprBinary(binop, ref lhs, ref rhs) => {
183182

184-
match implements_ord(self.cx, lhs) {
185-
Some(true) => (),
186-
_ => return None,
187-
};
183+
if !implements_ord(self.cx, lhs) {
184+
return None;
185+
}
188186

189187
match binop.node {
190188
BiEq => Some(" != "),
@@ -458,12 +456,9 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
458456
}
459457

460458

461-
fn implements_ord<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, expr: &Expr) -> Option<bool> {
459+
fn implements_ord<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, expr: &Expr) -> bool {
462460
let ty = cx.tables.expr_ty(expr);
463-
464-
return if let Some(id) = get_trait_def_id(cx, &paths::ORD) {
465-
Some(implements_trait(cx, ty, id, &[]))
466-
} else {
467-
None
468-
};
461+
get_trait_def_id(cx, &paths::ORD)
462+
.map(|id| implements_trait(cx, ty, id, &[]))
463+
.unwrap_or(false)
469464
}

0 commit comments

Comments
 (0)