use crate::utils::span_lint;
use rustc::hir;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::{declare_tool_lint, lint_array};
+use rustc::{declare_tool_lint, impl_lint_pass};
use syntax::source_map::Span;
declare_clippy_lint! {
///
/// **Example:**
/// ```rust
- /// a + 1
+ /// # let a = 0;
+ /// a + 1;
/// ```
pub INTEGER_ARITHMETIC,
restriction,
///
/// **Example:**
/// ```rust
- /// a + 1.0
+ /// # let a = 0.0;
+ /// a + 1.0;
/// ```
pub FLOAT_ARITHMETIC,
restriction,
const_span: Option<Span>,
}
-impl LintPass for Arithmetic {
- fn get_lints(&self) -> LintArray {
- lint_array!(INTEGER_ARITHMETIC, FLOAT_ARITHMETIC)
- }
-
- fn name(&self) -> &'static str {
- "Arithmetic"
- }
-}
+impl_lint_pass!(Arithmetic => [INTEGER_ARITHMETIC, FLOAT_ARITHMETIC]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
return;
}
}
- match &expr.node {
- hir::ExprKind::Binary(op, l, r) => {
+ match &expr.kind {
+ hir::ExprKind::Binary(op, l, r) | hir::ExprKind::AssignOp(op, l, r) => {
match op.node {
hir::BinOpKind::And
| hir::BinOpKind::Or