Unhelpful rustdoc [src] link for struct generated by macro #47817
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-dev-tools
Relevant to the dev-tools subteam, which will review and decide on the PR/issue.
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
In dtolnay/syn#304 we have a macro_rules macro that adds some derive attributes to most of our syntax tree structs. Conceptually it looks like this:
In our case the macro definition and invocation are always in different files but the code above is sufficient to reproduce the issue. If you document this code with
cargo doc
, the [src] link at the top of struct.S.html points to the linepub struct $name $body
, as far as I can tell because this is where the first non-attribute token (pub
) of the final struct definition came from.I propose that it would be more often correct to have [src] point to wherever the *name* token of the item came from, in this case the $name token which originates from the line
pub struct S
.The text was updated successfully, but these errors were encountered: