]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/precedence.rs
Merge branch 'macro-use' into HEAD
[rust.git] / clippy_lints / src / precedence.rs
index e06c571b6f6d885f0cbcc2a963d28185dae6f3db..76ea9c5ade609ea95a73ade1166961340ebdd904 100644 (file)
@@ -1,7 +1,8 @@
 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:
@@ -20,9 +21,9 @@
 /// **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"
 }
 
@@ -37,6 +38,10 @@ fn get_lints(&self) -> LintArray {
 
 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(