Rustdoc links to std - rendering on local verification build

Rustdoc allows linking to std elements either directly by name [IntoIterator] or explicitly disambiguated [IntoIterator](std::iter::IntoIterator).

The hover and in-IDE links from rust-analyzer suggest that the links I have in place all work fine.

But when I build the docs locally to verify in a browser (both with or without --no-deps), the links don't render. The first shows as [IntoIterator], the second as IntoIterator (which points to an invalid url)

Is there any way to get cargo doc to build the local docs and place valid links to the online stdlib docs? All the RFCs, forum posts etc I could find were about using a locally hosted version of stdlib docs and I can't see how to bend any of them to this need.

I can't reproduce the behavior, the generated doc contains a valid link to doc.rust-lang.org.

how did you install the rust toolchain, is it installed via rustup or from your operating system package manager? if rustup, what's the profile or components being installed? e.g. what's the output of rustup component list --installed?

  • rust is installed via rustup
  • docs generated with cargo doc
  • served locally with cargo server --path target/doc
  • viewed at 127.0.0.1:8000/cratename

it's also reproducible (blazingly slowly :wink:) in a codespace at github.com/MusicalNinjaDad/try_v2:

  • cargo doc
  • cargo server --path target/doc
  • click the link to the forwarded port 8000
  • extend the uri to the page /try_v2/derive.IntoIterator.html
  • see links in first sentence

I've not published this version yet, so there is a chance I did something blazingly stupid when updating the docs myself and they won't render on docs.rs either ... but if I did, I really can't see it

I cloned your repo and find the problem is related to re-exported procedural macro.

the links work fine when you visit the documentation of the try_v2_derive crate, but they broke on the page of the re-exported item in the try_v2 crate.

I don't know if this is a known bug, a quick search found these similar titles, but I don't think they are actually related to your case.

maybe open a new bug report if it has not been reported yet.

Thanks I hadn't spotted that. I've just published v0.10.0 and the same occurs on docs.rs - it looks like a bug / limitation in rustdoc so I'll look at opening an issue or adding to an existing one

for future people finding this via a search ...

This appears to only be for derive macros / possibly for all proc_macros and does not occur for similarly re-exported traits.