-use crate::utils::{in_macro, snippet_with_applicability, span_lint_and_sugg};
+use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
+use rustc::declare_lint_pass;
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
-use rustc::{declare_lint_pass, declare_tool_lint};
use rustc_errors::Applicability;
+use rustc_session::declare_tool_lint;
use syntax::ast::*;
use syntax::source_map::Spanned;
impl EarlyLintPass for Precedence {
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
- if in_macro(expr.span) {
+ if expr.span.from_expansion() {
return;
}
- if let ExprKind::Binary(Spanned { node: op, .. }, ref left, ref right) = expr.node {
+ if let ExprKind::Binary(Spanned { node: op, .. }, ref left, ref right) = expr.kind {
let span_sugg = |expr: &Expr, sugg, appl| {
span_lint_and_sugg(
cx,
}
}
- if let ExprKind::Unary(UnOp::Neg, ref rhs) = expr.node {
- if let ExprKind::MethodCall(_, ref args) = rhs.node {
+ if let ExprKind::Unary(UnOp::Neg, ref rhs) = expr.kind {
+ if let ExprKind::MethodCall(_, ref args) = rhs.kind {
if let Some(slf) = args.first() {
- if let ExprKind::Lit(ref lit) = slf.node {
- match lit.node {
- LitKind::Int(..) | LitKind::Float(..) | LitKind::FloatUnsuffixed(..) => {
+ if let ExprKind::Lit(ref lit) = slf.kind {
+ match lit.kind {
+ LitKind::Int(..) | LitKind::Float(..) => {
let mut applicability = Applicability::MachineApplicable;
span_lint_and_sugg(
cx,
}
fn is_arith_expr(expr: &Expr) -> bool {
- match expr.node {
+ match expr.kind {
ExprKind::Binary(Spanned { node: op, .. }, _, _) => is_arith_op(op),
_ => false,
}
}
+#[must_use]
fn is_bit_op(op: BinOpKind) -> bool {
use syntax::ast::BinOpKind::*;
match op {
}
}
+#[must_use]
fn is_arith_op(op: BinOpKind) -> bool {
use syntax::ast::BinOpKind::*;
match op {