Skip to content

Commit d88e51d

Browse files
committed
fix(doctest): Include all search paths with new build layout
Part of #15010
1 parent 0e8fefa commit d88e51d

File tree

4 files changed

+2
-27
lines changed

4 files changed

+2
-27
lines changed

src/cargo/core/compiler/build_runner/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
234234
if unit.mode.is_doc_test() {
235235
let mut unstable_opts = false;
236236
let mut args = compiler::extern_args(&self, unit, &mut unstable_opts)?;
237+
args.extend(compiler::lib_search_paths(&self, unit)?);
237238
args.extend(compiler::lto_args(&self, unit));
238239
args.extend(compiler::features_args(unit));
239240
args.extend(compiler::check_cfg_args(unit));

src/cargo/core/compiler/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ fn add_custom_flags(
18201820
}
18211821

18221822
/// Generate a list of `-L` arguments
1823-
fn lib_search_paths(
1823+
pub fn lib_search_paths(
18241824
build_runner: &BuildRunner<'_, '_>,
18251825
unit: &Unit,
18261826
) -> CargoResult<Vec<OsString>> {

src/cargo/ops/cargo_test.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,6 @@ fn run_doc_tests(
229229
p.arg("-C").arg(format!("panic={}", unit.profile.panic));
230230
}
231231

232-
for &rust_dep in &[
233-
&compilation.deps_output[&unit.kind],
234-
&compilation.deps_output[&CompileKind::Host],
235-
] {
236-
let mut arg = OsString::from("dependency=");
237-
arg.push(rust_dep);
238-
p.arg("-L").arg(arg);
239-
}
240-
241232
for native_dep in compilation.native_dirs.iter() {
242233
p.arg("-L").arg(native_dep);
243234
}

tests/testsuite/test.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,23 +2629,6 @@ fn doctest_dep_new_layout() {
26292629

26302630
p.cargo("-Zbuild-dir-new-layout test")
26312631
.masquerade_as_nightly_cargo(&["new build-dir layout"])
2632-
.with_status(101)
2633-
.with_stdout_data(str![[r#"
2634-
...
2635-
error[E0463]: can't find crate for `b` which `foo` depends on
2636-
...
2637-
2638-
"#]])
2639-
.with_stderr_data(str![[r#"
2640-
[LOCKING] 1 package to latest compatible version
2641-
[COMPILING] b v0.0.1 ([ROOT]/foo/b)
2642-
[COMPILING] foo v0.0.1 ([ROOT]/foo)
2643-
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2644-
[RUNNING] unittests src/lib.rs (target/debug/build/foo/[HASH]/deps/foo-[HASH])
2645-
[DOCTEST] foo
2646-
[ERROR] doctest failed, to rerun pass `--doc`
2647-
2648-
"#]])
26492632
.run();
26502633
}
26512634

0 commit comments

Comments
 (0)