Skip to content

No way to support cargo -Zrustdoc-map with re-exported docs from a proc-macro #110183

Open
@Nemo157

Description

@Nemo157

Setup a pair of crates, the first a proc-macro linking to a dependency and the second re-exporting from the first:

> cargo new --lib foo
     Created library `foo` package
> cat <<END >> foo/Cargo.toml
bs58.version = "0.3"
[lib]
proc-macro = true
END
> cat <<'END' > foo/src/lib.rs
/// [`bs58::Alphabet`]
#[proc_macro]
pub fn foo(t: proc_macro::TokenStream) -> proc_macro::TokenStream { t }
END

> cargo new --lib bar
     Created library `bar` package
> echo 'foo.path = "../foo"' >> bar/Cargo.toml
> echo 'pub use foo::foo;' >> bar/src/lib.rs

Now build the docs for the second crate, using -Zrustdoc-map to link dependencies to docs.rs:

> cd bar && cargo rustdoc -Z rustdoc-map --config "doc.extern-map.registries.crates-io=\"https://docs.rs/{pkg_name}/{version}/x86_64-unknown-linux-gnu\""
   Compiling bs58 v0.3.1
   Compiling foo v0.1.0 (/tmp/tmp.VUf54czzNC/foo)
 Documenting bar v0.1.0 (/tmp/tmp.VUf54czzNC/bar)
    Finished dev [unoptimized + debuginfo] target(s) in 0.74s

Expected: Open the docs and the re-exported bar::foo has a resolved link to bs58::Alphabet.
Actual: The link is missing

Prior to #94857 it was possible to hack this into working by adding bs58 as a dependency of bar too, but since that change that no longer works for proc-macro intermediary crates; it still works for non-proc-macros as I assume the crate ids get unified somehow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-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