-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-rustdoc-jsonArea: Rustdoc JSON backendArea: Rustdoc JSON backendC-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
Rustdoc uses crate name as a base for file names (target/doc/$name.json
), but this naming scheme is incompatible with Cargo projects where names are not unique, and multiple different crates can have the same name.
[package]
name = "exampledoc" # try `name = "wild"` for extra difficulty
edition = "2024"
[dependencies]
old = { package = "wild", version = "1" }
new = { package = "wild", version = "2" }
pub use ::old;
pub use ::new;
RUSTDOCFLAGS="-Z unstable-options --output-format=json" cargo +nightly doc
This ends up writing target/doc/wild.json
for only one of the two versions. The same problem can happen if Cargo has git
, path
, or custom registry dependencies that use names overlapping with crates-io dependencies, so even name + version isn't unique.
Using the package alias (new
and old
in this example) wouldn't be sufficient, because these aliases aren't globally unique either. Different crates in the same dependency tree can rename different deps to the same name.
cargo 1.89.0-nightly (fc1518ef0 2025-06-06)
Metadata
Metadata
Assignees
Labels
A-rustdoc-jsonArea: Rustdoc JSON backendArea: Rustdoc JSON backendC-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.