@@ -16,7 +16,7 @@ use std::{fmt, panic, str};
16
16
17
17
pub ( crate ) use make:: { BuildDocTestBuilder , DocTestBuilder } ;
18
18
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 } ;
20
20
use rustc_errors:: emitter:: HumanReadableErrorType ;
21
21
use rustc_errors:: { ColorConfig , DiagCtxtHandle } ;
22
22
use rustc_hir as hir;
@@ -689,6 +689,10 @@ fn run_test(
689
689
"--extern=doctest_bundle_{edition}=" ,
690
690
edition = doctest. edition
691
691
) ) ;
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 ( ) ;
692
696
for extern_str in & rustdoc_options. extern_strs {
693
697
if let Some ( ( _cratename, path) ) = extern_str. split_once ( '=' ) {
694
698
// Direct dependencies of the tests themselves are
@@ -698,7 +702,9 @@ fn run_test(
698
702
. parent ( )
699
703
. filter ( |x| x. components ( ) . count ( ) > 0 )
700
704
. 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
+ }
702
708
}
703
709
}
704
710
let output_bundle_file = doctest
0 commit comments