Skip to content

Commit 31dd541

Browse files
committed
Add {target} to the extern-html-root-url
This avoids cross-crate intra-doc links that go to the wrong platform, and possibly to items that don't exist.
1 parent ae66335 commit 31dd541

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/docbuilder/rustwide_builder.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,17 @@ impl RustwideBuilder {
580580
// We know that `metadata` unconditionally passes `-Z rustdoc-map`.
581581
// Don't copy paste this, since that fact is not stable and may change in the future.
582582
"-Zunstable-options".into(),
583-
r#"--config=doc.extern-map.registries.crates-io="https://docs.rs""#.into(),
583+
// Add `target` so that if a dependency has target-specific docs, this links to them properly.
584+
//
585+
// Note that this includes the target even if this is the default, since the dependency
586+
// may have a different default (and the web backend will take care of redirecting if
587+
// necessary).
588+
//
589+
// FIXME: host-only crates like proc-macros should probably not have this passed? but #1417 should make it OK
590+
format!(
591+
r#"--config=doc.extern-map.registries.crates-io="https://docs.rs/{{pkg_name}}/{{version}}/{}""#,
592+
target
593+
),
584594
];
585595
if let Some(cpu_limit) = self.config.build_cpu_limit {
586596
cargo_args.push(format!("-j{}", cpu_limit));

0 commit comments

Comments
 (0)