//! This lint is **warn** by default
use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg};
+use clippy_utils::higher;
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::sugg::Sugg;
use clippy_utils::{is_else_clause, is_expn_of};
if e.span.from_expansion() {
return;
}
- if let ExprKind::If(pred, then_block, Some(else_expr)) = e.kind {
+ if let Some(higher::If {
+ cond,
+ then,
+ r#else: Some(r#else),
+ }) = higher::If::hir(e)
+ {
let reduce = |ret, not| {
let mut applicability = Applicability::MachineApplicable;
- let snip = Sugg::hir_with_applicability(cx, pred, "<predicate>", &mut applicability);
+ let snip = Sugg::hir_with_applicability(cx, cond, "<predicate>", &mut applicability);
let mut snip = if not { !snip } else { snip };
if ret {
applicability,
);
};
- if let ExprKind::Block(then_block, _) = then_block.kind {
- match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) {
+ if let ExprKind::Block(then, _) = then.kind {
+ match (fetch_bool_block(then), fetch_bool_expr(r#else)) {
(RetBool(true), RetBool(true)) | (Bool(true), Bool(true)) => {
span_lint(
cx,
if l_ty.is_bool() && r_ty.is_bool() {
let mut applicability = Applicability::MachineApplicable;
- if let BinOpKind::Eq = op.node {
+ if op.node == BinOpKind::Eq {
let expression_info = one_side_is_unary_not(left_side, right_side);
if expression_info.one_side_is_unary_not {
span_lint_and_sugg(