Skip to content

Commit

Permalink
Address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
c410-f3r committed Feb 12, 2023
1 parent e70a7a6 commit 1ed8ed3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions clippy_lints/src/operators/arithmetic_side_effects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::ARITHMETIC_SIDE_EFFECTS;
use clippy_utils::{
consts::{constant, constant_simple, Constant},
diagnostics::span_lint,
peel_hir_expr_refs, peel_hir_expr_unary,
is_lint_allowed, peel_hir_expr_refs, peel_hir_expr_unary,
};
use rustc_ast as ast;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
Expand Down Expand Up @@ -191,14 +191,16 @@ impl ArithmeticSideEffects {
self.issue_lint(cx, expr);
}

fn should_skip_expr(&mut self, expr: &hir::Expr<'_>) -> bool {
self.expr_span.is_some() || self.const_span.map_or(false, |sp| sp.contains(expr.span))
fn should_skip_expr(&mut self, cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool {
is_lint_allowed(cx, ARITHMETIC_SIDE_EFFECTS, expr.hir_id)
|| self.expr_span.is_some()
|| self.const_span.map_or(false, |sp| sp.contains(expr.span))
}
}

impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &hir::Expr<'tcx>) {
if self.should_skip_expr(expr) {
if self.should_skip_expr(cx, expr) {
return;
}
match &expr.kind {
Expand Down

0 comments on commit 1ed8ed3

Please sign in to comment.