@@ -2,7 +2,7 @@ use super::ARITHMETIC_SIDE_EFFECTS;
22use clippy_utils:: {
33 consts:: { constant, constant_simple, Constant } ,
44 diagnostics:: span_lint,
5- peel_hir_expr_refs, peel_hir_expr_unary,
5+ is_lint_allowed , peel_hir_expr_refs, peel_hir_expr_unary,
66} ;
77use rustc_ast as ast;
88use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
@@ -191,14 +191,16 @@ impl ArithmeticSideEffects {
191191 self . issue_lint ( cx, expr) ;
192192 }
193193
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 ) )
196198 }
197199}
198200
199201impl < ' tcx > LateLintPass < ' tcx > for ArithmeticSideEffects {
200202 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) {
202204 return ;
203205 }
204206 match & expr. kind {
0 commit comments