From 21db004f585bf1477760556c0b9d0d11199f6643 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 22 Oct 2025 16:58:35 +0200 Subject: [PATCH] Fix invalid jump to def link generated on derive attributes --- src/librustdoc/html/render/span_map.rs | 3 +-- tests/rustdoc/jump-to-def-assoc-items.rs | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/render/span_map.rs b/src/librustdoc/html/render/span_map.rs index bc9417b1bb1de..257f5da877b56 100644 --- a/src/librustdoc/html/render/span_map.rs +++ b/src/librustdoc/html/render/span_map.rs @@ -7,7 +7,6 @@ use rustc_hir::intravisit::{self, Visitor, VisitorExt}; use rustc_hir::{ExprKind, HirId, Item, ItemKind, Mod, Node, QPath}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::TyCtxt; -use rustc_span::hygiene::MacroKind; use rustc_span::{BytePos, ExpnKind}; use crate::clean::{self, PrimitiveType, rustc_span}; @@ -194,7 +193,7 @@ impl SpanMapVisitor<'_> { } let macro_name = match data.kind { - ExpnKind::Macro(MacroKind::Bang, macro_name) => macro_name, + ExpnKind::Macro(_, macro_name) => macro_name, // Even though we don't handle this kind of macro, this `data` still comes from // expansion so we return `true` so we don't go any deeper in this code. _ => return true, diff --git a/tests/rustdoc/jump-to-def-assoc-items.rs b/tests/rustdoc/jump-to-def-assoc-items.rs index 8cbf990628386..0dfe3c7bdc155 100644 --- a/tests/rustdoc/jump-to-def-assoc-items.rs +++ b/tests/rustdoc/jump-to-def-assoc-items.rs @@ -26,6 +26,9 @@ impl C { pub fn wat() {} } +//@ has - '//a[@href="{{channel}}/core/fmt/macros/macro.Debug.html"]' 'Debug' +//@ has - '//a[@href="{{channel}}/core/cmp/macro.PartialEq.html"]' 'PartialEq' +#[derive(Debug, PartialEq)] pub struct Bar; impl Trait for Bar { type T = Foo;