From 7563f243db67db1a9070c10411fe244a6f6e2461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20M=2E=20Gonz=C3=A1lez?= Date: Wed, 12 Jun 2024 10:26:43 -0300 Subject: [PATCH 1/2] Also consider ^=. --- detectors/incorrect-exponentiation/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/detectors/incorrect-exponentiation/src/lib.rs b/detectors/incorrect-exponentiation/src/lib.rs index 4cbe3258..4bdf34bc 100644 --- a/detectors/incorrect-exponentiation/src/lib.rs +++ b/detectors/incorrect-exponentiation/src/lib.rs @@ -47,6 +47,14 @@ 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; From 3e71a76f566295b8817ab596a43b5f3e90557a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20M=2E=20Gonz=C3=A1lez?= Date: Wed, 12 Jun 2024 10:38:43 -0300 Subject: [PATCH 2/2] Passed through cargo fmt. --- detectors/incorrect-exponentiation/src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/detectors/incorrect-exponentiation/src/lib.rs b/detectors/incorrect-exponentiation/src/lib.rs index 4bdf34bc..898d1a2e 100644 --- a/detectors/incorrect-exponentiation/src/lib.rs +++ b/detectors/incorrect-exponentiation/src/lib.rs @@ -47,14 +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{ + 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;