Skip to content

Commit

Permalink
Merge pull request #241 from CoinFabrik/incorrect-exponentiation-impr…
Browse files Browse the repository at this point in the history
…ovement

Incorrect exponentiation improvement
  • Loading branch information
tenuki authored Jul 1, 2024
2 parents c5e9989 + 3e71a76 commit 276453d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions detectors/incorrect-exponentiation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ impl<'tcx> LateLintPass<'tcx> for IncorrectExponentiation {

impl<'tcx> Visitor<'tcx> for IncorrectExponentiationStorage {
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if let ExprKind::AssignOp(binop, _, _) = &expr.kind {
if binop.node == rustc_hir::BinOpKind::BitXor {
self.incorrect_exponentiation = true;
self.span.push(expr.span);
}
}

if let ExprKind::Binary(op, _, _) = &expr.kind {
if op.node == rustc_hir::BinOpKind::BitXor {
self.incorrect_exponentiation = true;
Expand Down

0 comments on commit 276453d

Please sign in to comment.