-use consts::{constant_simple, Constant};
+use crate::consts::{constant_simple, Constant};
use rustc::hir::*;
use rustc::lint::*;
+use rustc::{declare_lint, lint_array};
use syntax::codemap::Span;
-use utils::{in_macro, span_lint};
+use crate::utils::{in_macro, span_lint};
/// **What it does:** Checks for erasing operations, e.g. `x * 0`.
///
/// ```rust
/// 0 / x; 0 * x; x & 0
/// ```
-declare_lint! {
+declare_clippy_lint! {
pub ERASING_OP,
- Warn,
+ correctness,
"using erasing operations, e.g. `x * 0` or `y & 0`"
}
if in_macro(e.span) {
return;
}
- if let ExprBinary(ref cmp, ref left, ref right) = e.node {
+ if let ExprKind::Binary(ref cmp, ref left, ref right) = e.node {
match cmp.node {
- BiMul | BiBitAnd => {
+ BinOpKind::Mul | BinOpKind::BitAnd => {
check(cx, left, e.span);
check(cx, right, e.span);
},
- BiDiv => check(cx, left, e.span),
+ BinOpKind::Div => check(cx, left, e.span),
_ => (),
}
}
}
fn check(cx: &LateContext, e: &Expr, span: Span) {
- if let Some(Constant::Int(v)) = constant_simple(cx, e) {
+ if let Some(Constant::Int(v)) = constant_simple(cx, cx.tables, e) {
if v == 0 {
span_lint(
cx,