@@ -133,56 +133,57 @@ impl LintPass for BoolComparison {
133
133
134
134
impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for BoolComparison {
135
135
fn check_expr ( & mut self , cx : & LateContext < ' a , ' tcx > , e : & ' tcx Expr ) {
136
- if !in_macro ( e. span ) {
137
- use self :: Expression :: * ;
138
- if let ExprKind :: Binary ( Spanned { node : BinOpKind :: Eq , .. } , ref left_side, ref right_side) = e. node {
139
- match ( fetch_bool_expr ( left_side) , fetch_bool_expr ( right_side) ) {
140
- ( Bool ( true ) , Other ) => {
141
- let hint = snippet ( cx, right_side. span , ".." ) . into_owned ( ) ;
142
- span_lint_and_sugg (
143
- cx,
144
- BOOL_COMPARISON ,
145
- e. span ,
146
- "equality checks against true are unnecessary" ,
147
- "try simplifying it as shown" ,
148
- hint,
149
- ) ;
150
- } ,
151
- ( Other , Bool ( true ) ) => {
152
- let hint = snippet ( cx, left_side. span , ".." ) . into_owned ( ) ;
153
- span_lint_and_sugg (
154
- cx,
155
- BOOL_COMPARISON ,
156
- e. span ,
157
- "equality checks against true are unnecessary" ,
158
- "try simplifying it as shown" ,
159
- hint,
160
- ) ;
161
- } ,
162
- ( Bool ( false ) , Other ) => {
163
- let hint = Sugg :: hir ( cx, right_side, ".." ) ;
164
- span_lint_and_sugg (
165
- cx,
166
- BOOL_COMPARISON ,
167
- e. span ,
168
- "equality checks against false can be replaced by a negation" ,
169
- "try simplifying it as shown" ,
170
- ( !hint) . to_string ( ) ,
171
- ) ;
172
- } ,
173
- ( Other , Bool ( false ) ) => {
174
- let hint = Sugg :: hir ( cx, left_side, ".." ) ;
175
- span_lint_and_sugg (
176
- cx,
177
- BOOL_COMPARISON ,
178
- e. span ,
179
- "equality checks against false can be replaced by a negation" ,
180
- "try simplifying it as shown" ,
181
- ( !hint) . to_string ( ) ,
182
- ) ;
183
- } ,
184
- _ => ( ) ,
185
- }
136
+ if in_macro ( e. span ) {
137
+ return ;
138
+ }
139
+ use self :: Expression :: * ;
140
+ if let ExprKind :: Binary ( Spanned { node : BinOpKind :: Eq , .. } , ref left_side, ref right_side) = e. node {
141
+ match ( fetch_bool_expr ( left_side) , fetch_bool_expr ( right_side) ) {
142
+ ( Bool ( true ) , Other ) => {
143
+ let hint = snippet ( cx, right_side. span , ".." ) . into_owned ( ) ;
144
+ span_lint_and_sugg (
145
+ cx,
146
+ BOOL_COMPARISON ,
147
+ e. span ,
148
+ "equality checks against true are unnecessary" ,
149
+ "try simplifying it as shown" ,
150
+ hint,
151
+ ) ;
152
+ } ,
153
+ ( Other , Bool ( true ) ) => {
154
+ let hint = snippet ( cx, left_side. span , ".." ) . into_owned ( ) ;
155
+ span_lint_and_sugg (
156
+ cx,
157
+ BOOL_COMPARISON ,
158
+ e. span ,
159
+ "equality checks against true are unnecessary" ,
160
+ "try simplifying it as shown" ,
161
+ hint,
162
+ ) ;
163
+ } ,
164
+ ( Bool ( false ) , Other ) => {
165
+ let hint = Sugg :: hir ( cx, right_side, ".." ) ;
166
+ span_lint_and_sugg (
167
+ cx,
168
+ BOOL_COMPARISON ,
169
+ e. span ,
170
+ "equality checks against false can be replaced by a negation" ,
171
+ "try simplifying it as shown" ,
172
+ ( !hint) . to_string ( ) ,
173
+ ) ;
174
+ } ,
175
+ ( Other , Bool ( false ) ) => {
176
+ let hint = Sugg :: hir ( cx, left_side, ".." ) ;
177
+ span_lint_and_sugg (
178
+ cx,
179
+ BOOL_COMPARISON ,
180
+ e. span ,
181
+ "equality checks against false can be replaced by a negation" ,
182
+ "try simplifying it as shown" ,
183
+ ( !hint) . to_string ( ) ,
184
+ ) ;
185
+ } ,
186
+ _ => ( ) ,
186
187
}
187
188
}
188
189
}
0 commit comments