Skip to content

rustdoc can't handle some links on derive macros #117463

Open
@CryZe

Description

@CryZe

I tried this code:

/// The default value of the setting normally matches the
/// [`Default`] trait. If you want to specify a
#[proc_macro_derive(Gui, attributes(default, heading_level))]
pub fn settings_macro(input: TokenStream) -> TokenStream { ... }

When running cargo doc I expected to see this happen:

The Default trait is linked.

Instead, this happened:

image

The Default is not properly linked. There is no warning in the cargo doc output.

If I change it to:

/// The default value of the setting normally matches the
/// [`Default`](core::default::Default) trait. If you want to specify a
/// different default you can specify it like so:

It properly gets linked:

image

But now there is a warning:

warning: redundant explicit link target
  --> asr-derive\src\lib.rs:46:17
   |
46 | /// [`Default`](core::default::Default) trait. If you want to specify a
   |      ---------  ^^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant
   |      |
   |      because label contains path that resolves to same destination
   |
   = note: when a link's destination is not specified,
           the label is used to resolve intra-doc links
   = note: `#[warn(rustdoc::redundant_explicit_links)]` on by default
help: remove explicit link target
   |
46 | /// [`Default`] trait. If you want to specify a
   |     ~~~~~~~~~~~

Meta

rustc --version --verbose:

rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: x86_64-pc-windows-msvc
release: 1.73.0
LLVM version: 17.0.2
Backtrace

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameA-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions