@@ -2,7 +2,7 @@ use super::ARITHMETIC_SIDE_EFFECTS;
2
2
use clippy_utils:: {
3
3
consts:: { constant, constant_simple, Constant } ,
4
4
diagnostics:: span_lint,
5
- peel_hir_expr_refs, peel_hir_expr_unary,
5
+ is_lint_allowed , peel_hir_expr_refs, peel_hir_expr_unary,
6
6
} ;
7
7
use rustc_ast as ast;
8
8
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
@@ -191,14 +191,16 @@ impl ArithmeticSideEffects {
191
191
self . issue_lint ( cx, expr) ;
192
192
}
193
193
194
- fn should_skip_expr ( & mut self , expr : & hir:: Expr < ' _ > ) -> bool {
195
- self . expr_span . is_some ( ) || self . const_span . map_or ( false , |sp| sp. contains ( expr. span ) )
194
+ fn should_skip_expr ( & mut self , cx : & LateContext < ' _ > , expr : & hir:: Expr < ' _ > ) -> bool {
195
+ is_lint_allowed ( cx, ARITHMETIC_SIDE_EFFECTS , expr. hir_id )
196
+ || self . expr_span . is_some ( )
197
+ || self . const_span . map_or ( false , |sp| sp. contains ( expr. span ) )
196
198
}
197
199
}
198
200
199
201
impl < ' tcx > LateLintPass < ' tcx > for ArithmeticSideEffects {
200
202
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & hir:: Expr < ' tcx > ) {
201
- if self . should_skip_expr ( expr) {
203
+ if self . should_skip_expr ( cx , expr) {
202
204
return ;
203
205
}
204
206
match & expr. kind {
0 commit comments