Skip to content

Commit fd5b737

Browse files
committed
Do not pass duplicated -L arguments to merged doctests
1 parent 8b387d8 commit fd5b737

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/librustdoc/doctest.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{fmt, panic, str};
1616

1717
pub(crate) use make::{BuildDocTestBuilder, DocTestBuilder};
1818
pub(crate) use markdown::test as test_markdown;
19-
use rustc_data_structures::fx::{FxHashMap, FxHasher, FxIndexMap, FxIndexSet};
19+
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxHasher, FxIndexMap, FxIndexSet};
2020
use rustc_errors::emitter::HumanReadableErrorType;
2121
use rustc_errors::{ColorConfig, DiagCtxtHandle};
2222
use rustc_hir as hir;
@@ -689,6 +689,10 @@ fn run_test(
689689
"--extern=doctest_bundle_{edition}=",
690690
edition = doctest.edition
691691
));
692+
693+
// Deduplicate passed -L directory paths, since usually all dependencies will be in the
694+
// same directory (e.g. target/debug/deps from Cargo).
695+
let mut seen_search_dirs = FxHashSet::default();
692696
for extern_str in &rustdoc_options.extern_strs {
693697
if let Some((_cratename, path)) = extern_str.split_once('=') {
694698
// Direct dependencies of the tests themselves are
@@ -698,7 +702,9 @@ fn run_test(
698702
.parent()
699703
.filter(|x| x.components().count() > 0)
700704
.unwrap_or(Path::new("."));
701-
runner_compiler.arg("-L").arg(dir);
705+
if seen_search_dirs.insert(dir) {
706+
runner_compiler.arg("-L").arg(dir);
707+
}
702708
}
703709
}
704710
let output_bundle_file = doctest

0 commit comments

Comments
 (0)