Skip to content

Commit 47a06b7

Browse files
Simplify dependency arguments
1 parent 6961413 commit 47a06b7

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/librustdoc/doctest.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::{panic, str};
1818

1919
pub(crate) use make::{BuildDocTestBuilder, DocTestBuilder};
2020
pub(crate) use markdown::test as test_markdown;
21-
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxHasher, FxIndexMap, FxIndexSet};
21+
use rustc_data_structures::fx::{FxHashMap, FxHasher, FxIndexMap, FxIndexSet};
2222
use rustc_errors::emitter::HumanReadableErrorType;
2323
use rustc_errors::{ColorConfig, DiagCtxtHandle};
2424
use rustc_hir as hir;
@@ -589,22 +589,11 @@ fn compile_merged_doctest_and_caller_binary(
589589
format!("doctest_bundle_{edition}", edition = doctest.edition)
590590
};
591591

592-
// Deduplicate passed -L directory paths, since usually all dependencies will be in the
593-
// same directory (e.g. target/debug/deps from Cargo).
594-
let mut seen_search_dirs = FxHashSet::default();
592+
for lib_str in &rustdoc_options.lib_strs {
593+
runner_compiler.arg(format!("-L{lib_str}"));
594+
}
595595
for extern_str in &rustdoc_options.extern_strs {
596-
if let Some((_cratename, path)) = extern_str.split_once('=') {
597-
// Direct dependencies of the tests themselves are
598-
// indirect dependencies of the test runner.
599-
// They need to be in the library search path.
600-
let dir = Path::new(path)
601-
.parent()
602-
.filter(|x| x.components().count() > 0)
603-
.unwrap_or(Path::new("."));
604-
if seen_search_dirs.insert(dir) {
605-
runner_compiler.arg("-L").arg(dir);
606-
}
607-
}
596+
runner_compiler.arg(format!("--extern={extern_str}"));
608597
}
609598
let output_bundle_file = doctest.test_opts.outdir.path().join(format!("lib{base_name}.rlib"));
610599
let mut extern_path = std::ffi::OsString::from(format!("--extern={base_name}="));

0 commit comments

Comments
 (0)