Skip to content

Commit b30cc1e

Browse files
notriddlecuviper
authored andcommitted
doctests: fix merging on stable
Fixes rust-lang#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. (cherry picked from commit 5d6eeea)
1 parent 3aa36cf commit b30cc1e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librustdoc/doctest.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,12 @@ fn run_test(
525525
}
526526

527527
compiler.arg("--edition").arg(doctest.edition.to_string());
528-
if !doctest.is_multiple_tests {
528+
if doctest.is_multiple_tests {
529+
// The merged test harness uses the `test` crate, so we need to actually allow it.
530+
// This will not expose nightly features on stable, because crate attrs disable
531+
// merging, and `#![feature]` is required to be a crate attr.
532+
compiler.env("RUSTC_BOOTSTRAP", "1");
533+
} else {
529534
// Setting these environment variables is unneeded if this is a merged doctest.
530535
compiler.env("UNSTABLE_RUSTDOC_TEST_PATH", &doctest.test_opts.path);
531536
compiler.env(

0 commit comments

Comments
 (0)