@@ -2,7 +2,6 @@ use clippy_utils::consts::{constant_full_int, FullInt};
2
2
use clippy_utils:: diagnostics:: span_lint_and_sugg;
3
3
use clippy_utils:: source:: snippet_with_applicability;
4
4
use clippy_utils:: { meets_msrv, msrvs, path_to_local} ;
5
- use if_chain:: if_chain;
6
5
use rustc_errors:: Applicability ;
7
6
use rustc_hir:: { BinOpKind , Expr , ExprKind , Node , TyKind } ;
8
7
use rustc_lint:: { LateContext , LateLintPass } ;
@@ -52,26 +51,22 @@ impl<'tcx> LateLintPass<'tcx> for ManualRemEuclid {
52
51
return ;
53
52
}
54
53
55
- if_chain ! {
56
- if let ExprKind :: Binary ( op1, ..) = expr. kind;
57
- if op1. node == BinOpKind :: Rem ;
58
- if let Some ( ( const1, expr1) ) = check_for_positive_int_constant( cx, expr, false ) ;
59
- if let ExprKind :: Binary ( op2, ..) = expr1. kind;
60
- if op2. node == BinOpKind :: Add ;
61
- if let Some ( ( const2, expr2) ) = check_for_positive_int_constant( cx, expr1, true ) ;
62
- if let ExprKind :: Binary ( op3, ..) = expr2. kind;
63
- if op3. node == BinOpKind :: Rem ;
64
- if let Some ( ( const3, expr3) ) = check_for_positive_int_constant( cx, expr2, false ) ;
65
- if const1 == const2 && const2 == const3;
54
+ if let ExprKind :: Binary ( op1, ..) = expr. kind
55
+ && op1. node == BinOpKind :: Rem
56
+ && let Some ( ( const1, expr1) ) = check_for_positive_int_constant ( cx, expr, false )
57
+ && let ExprKind :: Binary ( op2, ..) = expr1. kind
58
+ && op2. node == BinOpKind :: Add
59
+ && let Some ( ( const2, expr2) ) = check_for_positive_int_constant ( cx, expr1, true )
60
+ && let ExprKind :: Binary ( op3, ..) = expr2. kind
61
+ && op3. node == BinOpKind :: Rem
62
+ && let Some ( ( const3, expr3) ) = check_for_positive_int_constant ( cx, expr2, false )
63
+ && const1 == const2 && const2 == const3
66
64
// Only apply if we see an explicit type annotation on the local.
67
- if let Some ( hir_id) = path_to_local( expr3) ;
68
- let hir = cx. tcx. hir( ) ;
69
- if let Some ( Node :: Binding ( _) ) = hir. find( hir_id) ;
70
- let parent = hir. get_parent_node( hir_id) ;
71
- if let Some ( Node :: Local ( local) ) = hir. find( parent) ;
72
- if let Some ( ty) = local. ty;
73
- if !matches!( ty. kind, TyKind :: Infer ) ;
74
- then {
65
+ && let Some ( hir_id) = path_to_local ( expr3)
66
+ && let Some ( Node :: Binding ( _) ) = cx. tcx . hir ( ) . find ( hir_id)
67
+ && let Some ( Node :: Local ( local) ) = cx. tcx . hir ( ) . find ( cx. tcx . hir ( ) . get_parent_node ( hir_id) )
68
+ && let Some ( ty) = local. ty
69
+ && !matches ! ( ty. kind, TyKind :: Infer ) {
75
70
let mut app = Applicability :: MachineApplicable ;
76
71
let rem_of = snippet_with_applicability ( cx, expr3. span , "_" , & mut app) ;
77
72
span_lint_and_sugg (
@@ -83,7 +78,6 @@ impl<'tcx> LateLintPass<'tcx> for ManualRemEuclid {
83
78
format ! ( "{rem_of}.rem_euclid({const1})" ) ,
84
79
app,
85
80
) ;
86
- }
87
81
}
88
82
}
89
83
0 commit comments