Skip to content

Commit d7727ef

Browse files
authored
doctests: fix merging on stable
Fixes #137898 The generated multi-test harness relies on nightly-only APIs, so the only way to run it on stable is to enable them. Since tests that use crate attrs don't be merged, there's no way to use nightly-only features on it anyway.
1 parent 7c4a55c commit d7727ef

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librustdoc/doctest.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,12 @@ fn run_test(
550550
}
551551

552552
compiler.arg("--edition").arg(doctest.edition.to_string());
553-
if !doctest.is_multiple_tests {
553+
if doctest.is_multiple_tests {
554+
// The merged test harness uses the `test` crate, so we need to actually allow it.
555+
// This will not expose nightly features on stable, because crate attrs disable
556+
// merging, and `#![feature]` is required to be a crate attr.
557+
compiler.env("RUSTC_BOOTSTRAP", "1");
558+
} else {
554559
// Setting these environment variables is unneeded if this is a merged doctest.
555560
compiler.env("UNSTABLE_RUSTDOC_TEST_PATH", &doctest.test_opts.path);
556561
compiler.env(

0 commit comments

Comments
 (0)