Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--extern-html-root-url uses library names to identify dependencies, failing to handle multiple versions #76296

Open
Nemo157 opened this issue Sep 3, 2020 · 3 comments
Labels
C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Nemo157
Copy link
Member

Nemo157 commented Sep 3, 2020

With this package that uses dependency renaming:

# Cargo.toml

[package]
name = "foobar"
version = "0.1.0"
edition = "2018"

[dependencies]
ac = { package = "async-compression", features = ["stream", "gzip"], version = "0.3" }
ac02 = { package = "async-compression", features = ["stream", "gzip"], version = "0.2" }
// src/main.rs

#[doc(inline)]
pub use {ac::stream::GzipDecoder, ac02::stream::GzipDecoder as GzipDecoder02};
#[doc(no_inline)]
pub use {ac::stream::GzipEncoder, ac02::stream::GzipEncoder as GzipEncoder02};

I tried to build documentation that can link to both of the upstream docs.rs documentation pages:

cargo rustdoc --locked -- -Z unstable-options
--extern-html-root-url ac02=https://docs.rs/async-compression/0.2.0
--extern-html-root-url ac=https://docs.rs/async-compression/0.3.5
rustdoc
--edition=2018
--crate-type lib
--crate-name foobar src/lib.rs
-o /tmp/tmp.ni0GV7DIZf/foobar/target/doc
--error-format=json --json=diagnostic-rendered-ansi
-Z unstable-options
--extern-html-root-url 'ac02=https://docs.rs/async-compression/0.2.0'
--extern-html-root-url 'ac=https://docs.rs/async-compression/0.3.5'
-L dependency=/tmp/tmp.ni0GV7DIZf/async-compression/target/debug/deps
--extern ac02=/tmp/tmp.ni0GV7DIZf/foobar/target/debug/deps/libasync_compression-ad6b882a4c15a1f0.rmeta
--extern ac=/tmp/tmp.ni0GV7DIZf/foobar/target/debug/deps/libasync_compression-875810b2ce8d0002.rmeta
--crate-version 0.1.0

This failed to link to either of the non-inlined exports because it seems that --extern-html-root-url expects the library name instead, changing to use that:

cargo rustdoc --locked -- -Z unstable-options
--extern-html-root-url async_compression=https://docs.rs/async-compression/0.2.0
--extern-html-root-url async_compression=https://docs.rs/async-compression/0.3.5
rustdoc
--edition=2018
--crate-type lib
--crate-name foobar src/lib.rs
-o /tmp/tmp.ni0GV7DIZf/foobar/target/doc
--error-format=json --json=diagnostic-rendered-ansi
-Z unstable-options
--extern-html-root-url 'async_compression=https://docs.rs/async-compression/0.2.0'
--extern-html-root-url 'async_compression=https://docs.rs/async-compression/0.3.5'
-L dependency=/tmp/tmp.ni0GV7DIZf/async-compression/target/debug/deps
--extern ac02=/tmp/tmp.ni0GV7DIZf/foobar/target/debug/deps/libasync_compression-ad6b882a4c15a1f0.rmeta
--extern ac=/tmp/tmp.ni0GV7DIZf/foobar/target/debug/deps/libasync_compression-875810b2ce8d0002.rmeta
--crate-version 0.1.0

This successfully added links on both, but both directing to version 0.3.5 since that was the last flag specified.

(I'm not sure of the correct solution for this, currently docs.rs only passes --extern-html-root-url for direct dependencies, so changing to use the same name as used for --extern would work for that; but it seems to me that docs.rs should be passing a flag for all dependencies, since it's possible for documentation from a dependency of a dependency to bubble-up and be rendered, so it should be possible to set the html-root-url for them all, I'm not sure how we would identify the crates in that case).

Meta

rustdoc 1.47.0-nightly (7e6d6e5f5 2020-08-16)
@Nemo157 Nemo157 added the C-bug Category: This is a bug. label Sep 3, 2020
@jyn514 jyn514 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Sep 3, 2020
@Nemo157
Copy link
Member Author

Nemo157 commented Sep 3, 2020

An idea for supporting all dependencies, we could run a first cargo check --message-format=json and extract all the .rmeta filenames for all crates built, then pass flags using those as the key instead

--extern-html-root-url libasync_compression-ad6b882a4c15a1f0.rmeta=https://docs.rs/async-compression/0.2.0
--extern-html-root-url libasync_compression-875810b2ce8d0002.rmeta=https://docs.rs/async-compression/0.3.5

@jyn514 jyn514 added the requires-nightly This issue requires a nightly compiler in some way. label Sep 3, 2020
@jyn514
Copy link
Member

jyn514 commented Nov 6, 2020

This is basically the same as #56169, but I'll leave it open to make sure that someone remembers to update extern-html-root-url whenever the other issue gets fixed.

@Nemo157
Copy link
Member Author

Nemo157 commented Nov 7, 2020

Got a failing testcase at least: master...Nemo157:issue-76296.

I don't think this is really related to #56169 since this issue should be fixable without fixing that. If you have multiple crates with the same crate name, but different internally specified html-root-url it already works correctly. It's only the ability to override the html-root-url for a specific instance of the crate that is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants