@@ -2,7 +2,7 @@ use rustc::lint::*;
2
2
use rustc:: hir:: * ;
3
3
use utils:: { is_direct_expn_of, implements_trait, span_lint} ;
4
4
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
6
6
/// as `assert_eq!(x, y)` if `x` and `y` implement `Debug` trait.
7
7
///
8
8
/// **Why is this bad?** `assert_eq` provides better assertion failure reporting.
@@ -36,21 +36,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ShouldAssertEq {
36
36
let ExprIf ( ref cond, ..) = e. node,
37
37
let ExprUnary ( UnOp :: UnNot , ref cond) = cond. node,
38
38
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( ) ,
39
42
] , {
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
-
54
43
let ty1 = cx. tables. expr_ty( expr1) ;
55
44
let ty2 = cx. tables. expr_ty( expr2) ;
56
45
0 commit comments