/// **Why is this bad?** `if` is not guaranteed to be exhaustive and conditionals can get
/// repetitive
///
- /// **Known problems:** None.
+ /// **Known problems:** The match statement may be slower due to the compiler
+ /// not inlining the call to cmp. See issue [#5354](https://github.com/rust-lang/rust-clippy/issues/5354)
///
/// **Example:**
/// ```rust,ignore
}
// Check that the type being compared implements `core::cmp::Ord`
- let ty = cx.tables().expr_ty(lhs1);
+ let ty = cx.typeck_results().expr_ty(lhs1);
let is_ord = get_trait_def_id(cx, &paths::ORD).map_or(false, |id| implements_trait(cx, ty, id, &[]));
if !is_ord {
expr.span,
"`if` chain can be rewritten with `match`",
None,
- "Consider rewriting the `if` chain to use `cmp` and `match`.",
+ "consider rewriting the `if` chain to use `cmp` and `match`",
)
}
}
fn kind_is_cmp(kind: BinOpKind) -> bool {
- match kind {
- BinOpKind::Lt | BinOpKind::Gt | BinOpKind::Eq => true,
- _ => false,
- }
+ matches!(kind, BinOpKind::Lt | BinOpKind::Gt | BinOpKind::Eq)
}