diff options
| author | Michael Howell <michael@notriddle.com> | 2025-03-02 14:33:29 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2025-03-14 18:18:22 -0700 |
| commit | 6416d208a290fbe7c3b9803e7346e747c9345487 (patch) | |
| tree | 5cea2199dd263056c111731597d317fb0a3a094c | |
| parent | 6f5cf7d368c648da0c4400b158490e10ba09d6b4 (diff) | |
| download | rust-6416d208a290fbe7c3b9803e7346e747c9345487.tar.gz rust-6416d208a290fbe7c3b9803e7346e747c9345487.zip | |
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. (cherry picked from commit 5d6eeea5f969a5a3478de3904e9e02df68ce8b89)
| -rw-r--r-- | src/librustdoc/doctest.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 4a379b4235f..9c6cfb03110 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -550,7 +550,12 @@ fn run_test( } compiler.arg("--edition").arg(doctest.edition.to_string()); - if !doctest.is_multiple_tests { + if doctest.is_multiple_tests { + // The merged test harness uses the `test` crate, so we need to actually allow it. + // This will not expose nightly features on stable, because crate attrs disable + // merging, and `#![feature]` is required to be a crate attr. + compiler.env("RUSTC_BOOTSTRAP", "1"); + } else { // Setting these environment variables is unneeded if this is a merged doctest. compiler.env("UNSTABLE_RUSTDOC_TEST_PATH", &doctest.test_opts.path); compiler.env( |
