Skip to content

Rustdoc-map generation fails when using sparse registries #11402

@calebfletcher

Description

@calebfletcher

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

  1. Create an alternative registry that supports the sparse-registry interface.
  2. Upload a library crate to that registry.
  3. Create a new library crate that depends on the uploaded crate.
  4. Add a [doc.extern-map.registries] key corresponding to the registry.
  5. 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]

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions