]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/reference.rs
Auto merge of #4551 - mikerite:fix-ice-reporting, r=llogiq
[rust.git] / clippy_lints / src / reference.rs
index 2ee00a2f103470f7d92f8d926ae3ac53ad08b02f..54582c6015c2b1802346803b98d58241852ff8cd 100644 (file)
@@ -1,4 +1,4 @@
-use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
+use crate::utils::{in_macro, snippet_with_applicability, span_lint_and_sugg};
 use if_chain::if_chain;
 use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
 use rustc::{declare_lint_pass, declare_tool_lint};
@@ -15,7 +15,7 @@
     /// the suggested fix for `x = **&&y` is `x = *&y`, which is still incorrect.
     ///
     /// **Example:**
-    /// ```rust
+    /// ```rust,ignore
     /// let a = f(*&mut b);
     /// let c = *&d;
     /// ```
@@ -38,6 +38,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) {
         if_chain! {
             if let ExprKind::Unary(UnOp::Deref, ref deref_target) = e.node;
             if let ExprKind::AddrOf(_, ref addrof_target) = without_parens(deref_target).node;
+            if !in_macro(addrof_target.span);
             then {
                 let mut applicability = Applicability::MachineApplicable;
                 span_lint_and_sugg(
@@ -64,8 +65,8 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &Expr) {
     /// **Example:**
     /// ```rust
     /// struct Point(u32, u32);
-    /// let point = Foo(30, 20);
-    /// let x = (&point).x;
+    /// let point = Point(30, 20);
+    /// let x = (&point).0;
     /// ```
     pub REF_IN_DEREF,
     complexity,