Skip to content

Commit

Permalink
fix(rustdoc-map): dedup --extern-html-too-url for same unit
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Mar 6, 2024
1 parent 3c933e8 commit ac750a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/cargo/core/compiler/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::sources::CRATES_IO_REGISTRY;
use crate::util::errors::{internal, CargoResult};
use cargo_util::ProcessBuilder;
use std::collections::HashMap;
use std::collections::HashSet;
use std::fmt;
use std::hash;
use url::Url;
Expand Down Expand Up @@ -113,8 +114,12 @@ fn build_all_urls(
name2url: &HashMap<&String, Url>,
map: &RustdocExternMap,
unstable_opts: &mut bool,
seen: &mut HashSet<Unit>,
) {
for dep in build_runner.unit_deps(unit) {
if !seen.insert(dep.unit.clone()) {
continue;
}
if !dep.unit.target.is_linkable() || dep.unit.mode.is_doc() {
continue;
}
Expand Down Expand Up @@ -155,6 +160,7 @@ fn build_all_urls(
name2url,
map,
unstable_opts,
seen,
);
}
}
Expand Down Expand Up @@ -199,6 +205,7 @@ pub fn add_root_urls(
&name2url,
map,
&mut unstable_opts,
&mut HashSet::new(),
);
let std_url = match &map.std {
None | Some(RustdocExternMode::Remote) => None,
Expand Down
6 changes: 5 additions & 1 deletion tests/testsuite/rustdoc_extern_html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,14 @@ fn same_deps_multi_occurrence_in_dep_tree() {
.build();
p.cargo("doc -v --no-deps -Zrustdoc-map")
.masquerade_as_nightly_cargo(&["rustdoc-map"])
.with_stderr_contains(
.with_stderr_does_not_contain(
"[..]--extern-html-root-url[..]bar=https://docs.rs\
[..]--extern-html-root-url[..]baz=https://docs.rs\
[..]--extern-html-root-url[..]baz=https://docs.rs[..]",
)
.with_stderr_contains(
"[..]--extern-html-root-url[..]bar=https://docs.rs\
[..]--extern-html-root-url[..]baz=https://docs.rs[..]",
)
.run();
}

0 comments on commit ac750a1

Please sign in to comment.