Skip to content

Commit 30d7ed4

Browse files
committed
library/test: always enable unstable features for miri
The unstable features of the `test` crate used to be default-enabled, and manually disabled when building the beta and stable channels. Commit dae8ea9 flipped that to default-disabled, only enabled for nightly and dev channels. However, this broke miri testing on the beta/stable channels, because it also uses unstable features -- which should be fine to enable just for its own sysroot build. Now the `test` build script makes that happen by noticing the `MIRI_CALLED_FROM_SETUP` environment variable.
1 parent d2218f5 commit 30d7ed4

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

library/test/build.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ fn main() {
22
println!("cargo:rerun-if-changed=build.rs");
33
println!("cargo:rustc-check-cfg=cfg(enable_unstable_features)");
44

5-
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
6-
let version = std::process::Command::new(rustc).arg("-vV").output().unwrap();
7-
let stdout = String::from_utf8(version.stdout).unwrap();
5+
// Miri testing uses unstable features, so always enable that for its sysroot.
6+
// Otherwise, only enable unstable if rustc looks like a nightly or dev build.
7+
let enable_unstable_features = std::env::var("MIRI_CALLED_FROM_SETUP").is_ok() || {
8+
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
9+
let version = std::process::Command::new(rustc).arg("-vV").output().unwrap();
10+
let stdout = String::from_utf8(version.stdout).unwrap();
11+
stdout.contains("nightly") || stdout.contains("dev")
12+
};
813

9-
if stdout.contains("nightly") || stdout.contains("dev") {
14+
if enable_unstable_features {
1015
println!("cargo:rustc-cfg=enable_unstable_features");
1116
}
1217
}

0 commit comments

Comments
 (0)