Skip to content

Commit d2b9b7e

Browse files
committed
Fix language & if_let_chain usage
1 parent 8cb2ec8 commit d2b9b7e

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

clippy_lints/src/should_assert_eq.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc::lint::*;
22
use rustc::hir::*;
33
use utils::{is_direct_expn_of, implements_trait, span_lint};
44

5-
/// **What it does:** Checks for `assert!(x == y)` which can be written better
5+
/// **What it does:** Checks for `assert!(x == y)` which can be better written
66
/// as `assert_eq!(x, y)` if `x` and `y` implement `Debug` trait.
77
///
88
/// **Why is this bad?** `assert_eq` provides better assertion failure reporting.
@@ -36,21 +36,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ShouldAssertEq {
3636
let ExprIf(ref cond, ..) = e.node,
3737
let ExprUnary(UnOp::UnNot, ref cond) = cond.node,
3838
let ExprBinary(ref binop, ref expr1, ref expr2) = cond.node,
39+
binop.node == BinOp_::BiEq,
40+
is_direct_expn_of(cx, e.span, "assert").is_some(),
41+
let Some(debug_trait) = cx.tcx.lang_items.debug_trait(),
3942
], {
40-
if is_direct_expn_of(cx, e.span, "assert").is_none() {
41-
return;
42-
}
43-
44-
if binop.node != BinOp_::BiEq {
45-
return;
46-
}
47-
48-
let debug_trait = if let Some(t) = cx.tcx.lang_items.debug_trait() {
49-
t
50-
} else {
51-
return;
52-
};
53-
5443
let ty1 = cx.tables.expr_ty(expr1);
5544
let ty2 = cx.tables.expr_ty(expr2);
5645

0 commit comments

Comments
 (0)