use rustc::lint::*;
+use rustc::{declare_lint, lint_array};
use syntax::ast::*;
use syntax::codemap::Spanned;
-use utils::{snippet, span_lint_and_sugg};
+use crate::utils::{in_macro, snippet, span_lint_and_sugg};
/// **What it does:** Checks for operations where precedence may be unclear
/// and suggests to add parentheses. Currently it catches the following:
/// **Example:**
/// * `1 << 2 + 3` equals 32, while `(1 << 2) + 3` equals 7
/// * `-1i32.abs()` equals -1, while `(-1i32).abs()` equals 1
-declare_lint! {
+declare_clippy_lint! {
pub PRECEDENCE,
- Warn,
+ complexity,
"operations where precedence may be unclear"
}
impl EarlyLintPass for Precedence {
fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) {
+ if in_macro(expr.span) {
+ return;
+ }
+
if let ExprKind::Binary(Spanned { node: op, .. }, ref left, ref right) = expr.node {
let span_sugg = |expr: &Expr, sugg| {
span_lint_and_sugg(