]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/use_self.rs
Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-se
[rust.git] / clippy_lints / src / use_self.rs
index be7b9e9ff2dcc20186e58ec6409a3ce160987073..116cb8b1e1c70e5232a2368f68d3c3fa9d22dd3c 100644 (file)
@@ -1,6 +1,7 @@
-use crate::utils::{in_macro, meets_msrv, snippet_opt, span_lint_and_sugg};
+use clippy_utils::diagnostics::span_lint_and_sugg;
+use clippy_utils::source::snippet_opt;
+use clippy_utils::{in_macro, meets_msrv};
 use if_chain::if_chain;
-
 use rustc_errors::Applicability;
 use rustc_hir as hir;
 use rustc_hir::def::DefKind;
@@ -262,12 +263,17 @@ fn check_ty(&mut self, cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>) {
             // FIXME: this span manipulation should not be necessary
             // @flip1995 found an ast lowering issue in
             // https://github.com/rust-lang/rust/blob/master/src/librustc_ast_lowering/path.rs#l142-l162
-            match cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_ty.hir_id)) {
-                Some(Node::Expr(Expr {
-                    kind: ExprKind::Path(QPath::TypeRelative(_, segment)),
-                    ..
-                })) => span_lint_until_last_segment(cx, hir_ty.span, segment),
-                _ => span_lint(cx, hir_ty.span),
+            let hir = cx.tcx.hir();
+            let id = hir.get_parent_node(hir_ty.hir_id);
+
+            if !hir.opt_span(id).map_or(false, in_macro) {
+                match hir.find(id) {
+                    Some(Node::Expr(Expr {
+                        kind: ExprKind::Path(QPath::TypeRelative(_, segment)),
+                        ..
+                    })) => span_lint_until_last_segment(cx, hir_ty.span, segment),
+                    _ => span_lint(cx, hir_ty.span),
+                }
             }
         }
     }