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