Problem
When using -Zrustdoc-map and -Zsparse-registry to document crates that are on an alternative sparse registry, cargo does not output the --extern-html-root-url values for any crates that are on that registry.
This is caused by the following equality check:
|
return index_url == sid.url(); |
When a dependency comes from a sparse registry, sid.url() has a scheme of http, but the index_url (which is based on the rustdoc-map configuration) has a scheme of sparse+http. Since the equality operation of the Url type considers the scheme components, the equality always fails.
Sample URL Objects
sid.url()
Url { scheme: "http", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("localhost")), port: Some(1491), path: "/index/", query: None, fragment: None }
index_url
Url { scheme: "sparse+http", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("localhost")), port: Some(1491), path: "/index/", query: None, fragment: None }
Steps
- Create an alternative registry that supports the sparse-registry interface.
- Upload a library crate to that registry.
- Create a new library crate that depends on the uploaded crate.
- Add a
[doc.extern-map.registries] key corresponding to the registry.
- Run
cargo doc with -Zrustdoc-map.
Possible Solution(s)
The most straightforward fix is likely to compare if both URLs are sparse, and if so, compare the URLs with the sparse+ qualifier removed from the scheme.
Notes
No response
Version
cargo 1.67.0-nightly (eb5d35917 2022-11-17)
release: 1.67.0-nightly
commit-hash: eb5d35917b2395194593c9ca70c3778f60c1573b
commit-date: 2022-11-17
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.15.0 vendored)
libcurl: 7.86.0-DEV (sys:0.4.59+curl-7.86.0 vendored ssl:OpenSSL/1.1.1q)
os: Ubuntu 20.04 (focal) [64-bit]
Problem
When using
-Zrustdoc-mapand-Zsparse-registryto document crates that are on an alternative sparse registry, cargo does not output the--extern-html-root-urlvalues for any crates that are on that registry.This is caused by the following equality check:
cargo/src/cargo/core/compiler/rustdoc.rs
Line 135 in 6553589
When a dependency comes from a sparse registry,
sid.url()has a scheme ofhttp, but theindex_url(which is based on the rustdoc-map configuration) has a scheme ofsparse+http. Since the equality operation of theUrltype considers the scheme components, the equality always fails.Sample URL Objects
sid.url()index_urlSteps
[doc.extern-map.registries]key corresponding to the registry.cargo docwith-Zrustdoc-map.Possible Solution(s)
The most straightforward fix is likely to compare if both URLs are sparse, and if so, compare the URLs with the
sparse+qualifier removed from the scheme.Notes
No response
Version