@@ -62,58 +62,54 @@ impl IntPlusOne {
62
62
fn check_binop ( cx : & EarlyContext < ' _ > , binop : BinOpKind , lhs : & Expr , rhs : & Expr ) -> Option < String > {
63
63
match ( binop, & lhs. kind , & rhs. kind ) {
64
64
// case where `x - 1 >= ...` or `-1 + x >= ...`
65
- ( BinOpKind :: Ge , & ExprKind :: Binary ( ref lhskind, ref lhslhs, ref lhsrhs) , _) => {
65
+ ( BinOpKind :: Ge , ExprKind :: Binary ( lhskind, lhslhs, lhsrhs) , _) => {
66
66
match ( lhskind. node , & lhslhs. kind , & lhsrhs. kind ) {
67
67
// `-1 + x`
68
- ( BinOpKind :: Add , & ExprKind :: Lit ( ref lit) , _) if Self :: check_lit ( lit, -1 ) => {
68
+ ( BinOpKind :: Add , ExprKind :: Lit ( lit) , _) if Self :: check_lit ( lit, -1 ) => {
69
69
Self :: generate_recommendation ( cx, binop, lhsrhs, rhs, Side :: Lhs )
70
70
} ,
71
71
// `x - 1`
72
- ( BinOpKind :: Sub , _, & ExprKind :: Lit ( ref lit) ) if Self :: check_lit ( lit, 1 ) => {
72
+ ( BinOpKind :: Sub , _, ExprKind :: Lit ( lit) ) if Self :: check_lit ( lit, 1 ) => {
73
73
Self :: generate_recommendation ( cx, binop, lhslhs, rhs, Side :: Lhs )
74
74
} ,
75
75
_ => None ,
76
76
}
77
77
} ,
78
78
// case where `... >= y + 1` or `... >= 1 + y`
79
- ( BinOpKind :: Ge , _, & ExprKind :: Binary ( ref rhskind, ref rhslhs, ref rhsrhs) )
80
- if rhskind. node == BinOpKind :: Add =>
81
- {
79
+ ( BinOpKind :: Ge , _, ExprKind :: Binary ( rhskind, rhslhs, rhsrhs) ) if rhskind. node == BinOpKind :: Add => {
82
80
match ( & rhslhs. kind , & rhsrhs. kind ) {
83
81
// `y + 1` and `1 + y`
84
- ( & ExprKind :: Lit ( ref lit) , _) if Self :: check_lit ( lit, 1 ) => {
82
+ ( ExprKind :: Lit ( lit) , _) if Self :: check_lit ( lit, 1 ) => {
85
83
Self :: generate_recommendation ( cx, binop, rhsrhs, lhs, Side :: Rhs )
86
84
} ,
87
- ( _, & ExprKind :: Lit ( ref lit) ) if Self :: check_lit ( lit, 1 ) => {
85
+ ( _, ExprKind :: Lit ( lit) ) if Self :: check_lit ( lit, 1 ) => {
88
86
Self :: generate_recommendation ( cx, binop, rhslhs, lhs, Side :: Rhs )
89
87
} ,
90
88
_ => None ,
91
89
}
92
90
} ,
93
91
// case where `x + 1 <= ...` or `1 + x <= ...`
94
- ( BinOpKind :: Le , & ExprKind :: Binary ( ref lhskind, ref lhslhs, ref lhsrhs) , _)
95
- if lhskind. node == BinOpKind :: Add =>
96
- {
92
+ ( BinOpKind :: Le , ExprKind :: Binary ( lhskind, lhslhs, lhsrhs) , _) if lhskind. node == BinOpKind :: Add => {
97
93
match ( & lhslhs. kind , & lhsrhs. kind ) {
98
94
// `1 + x` and `x + 1`
99
- ( & ExprKind :: Lit ( ref lit) , _) if Self :: check_lit ( lit, 1 ) => {
95
+ ( ExprKind :: Lit ( lit) , _) if Self :: check_lit ( lit, 1 ) => {
100
96
Self :: generate_recommendation ( cx, binop, lhsrhs, rhs, Side :: Lhs )
101
97
} ,
102
- ( _, & ExprKind :: Lit ( ref lit) ) if Self :: check_lit ( lit, 1 ) => {
98
+ ( _, ExprKind :: Lit ( lit) ) if Self :: check_lit ( lit, 1 ) => {
103
99
Self :: generate_recommendation ( cx, binop, lhslhs, rhs, Side :: Lhs )
104
100
} ,
105
101
_ => None ,
106
102
}
107
103
} ,
108
104
// case where `... >= y - 1` or `... >= -1 + y`
109
- ( BinOpKind :: Le , _, & ExprKind :: Binary ( ref rhskind, ref rhslhs, ref rhsrhs) ) => {
105
+ ( BinOpKind :: Le , _, ExprKind :: Binary ( rhskind, rhslhs, rhsrhs) ) => {
110
106
match ( rhskind. node , & rhslhs. kind , & rhsrhs. kind ) {
111
107
// `-1 + y`
112
- ( BinOpKind :: Add , & ExprKind :: Lit ( ref lit) , _) if Self :: check_lit ( lit, -1 ) => {
108
+ ( BinOpKind :: Add , ExprKind :: Lit ( lit) , _) if Self :: check_lit ( lit, -1 ) => {
113
109
Self :: generate_recommendation ( cx, binop, rhsrhs, lhs, Side :: Rhs )
114
110
} ,
115
111
// `y - 1`
116
- ( BinOpKind :: Sub , _, & ExprKind :: Lit ( ref lit) ) if Self :: check_lit ( lit, 1 ) => {
112
+ ( BinOpKind :: Sub , _, ExprKind :: Lit ( lit) ) if Self :: check_lit ( lit, 1 ) => {
117
113
Self :: generate_recommendation ( cx, binop, rhslhs, lhs, Side :: Rhs )
118
114
} ,
119
115
_ => None ,
0 commit comments