Skip to content

Commit 1ed8ed3

Browse files
committed
Address comment
1 parent e70a7a6 commit 1ed8ed3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

clippy_lints/src/operators/arithmetic_side_effects.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::ARITHMETIC_SIDE_EFFECTS;
22
use 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
};
77
use rustc_ast as ast;
88
use 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

199201
impl<'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

Comments
 (0)