-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;
// 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),
+ }
}
}
}