]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/double_parens.rs
Auto merge of #4551 - mikerite:fix-ice-reporting, r=llogiq
[rust.git] / clippy_lints / src / double_parens.rs
index 5b5639371a188627ceeb6dc34fdc1ac7ef420636..5e1a860ae80fa895d0b224c802a5684944a43b6d 100644 (file)
@@ -1,6 +1,6 @@
-use crate::utils::{in_macro, span_lint};
+use crate::utils::span_lint;
 use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
-use rustc::{declare_tool_lint, lint_array};
+use rustc::{declare_lint_pass, declare_tool_lint};
 use syntax::ast::*;
 
 declare_clippy_lint! {
     ///
     /// **Example:**
     /// ```rust
-    /// ((0))
-    /// foo((0))
-    /// ((1, 2))
+    /// # fn foo(bar: usize) {}
+    /// ((0));
+    /// foo((0));
+    /// ((1, 2));
     /// ```
     pub DOUBLE_PARENS,
     complexity,
     "Warn on unnecessary double parentheses"
 }
 
-#[derive(Copy, Clone)]
-pub struct DoubleParens;
-
-impl LintPass for DoubleParens {
-    fn get_lints(&self) -> LintArray {
-        lint_array!(DOUBLE_PARENS)
-    }
-
-    fn name(&self) -> &'static str {
-        "DoubleParens"
-    }
-}
+declare_lint_pass!(DoubleParens => [DOUBLE_PARENS]);
 
 impl EarlyLintPass for DoubleParens {
     fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
-        if in_macro(expr.span) {
+        if expr.span.from_expansion() {
             return;
         }