diff --git a/crates/cargo-test-support/src/lib.rs b/crates/cargo-test-support/src/lib.rs index 55d345dc2e4..04471cadbba 100644 --- a/crates/cargo-test-support/src/lib.rs +++ b/crates/cargo-test-support/src/lib.rs @@ -1439,6 +1439,10 @@ pub trait TestEnvCommandExt: Sized { .env("CARGO_INCREMENTAL", "0") // Don't read the system git config which is out of our control. .env("GIT_CONFIG_NOSYSTEM", "1") + // See: https://github.com/rust-lang/rust/pull/159857#issuecomment-5119325932 + // This should be removed once the new build-dir layout is stabilized and the old layout + // is removed. + .env("__CARGO_TEMPORARY_BUILD_DIR_NEW_LAYOUT_OPT_OUT", "1") .env_remove("CI") .env_remove("__CARGO_DEFAULT_LIB_METADATA") .env_remove("ALL_PROXY") diff --git a/src/workspace/features.rs b/src/workspace/features.rs index c92b44d35f1..3eb25add58e 100644 --- a/src/workspace/features.rs +++ b/src/workspace/features.rs @@ -839,8 +839,10 @@ macro_rules! unstable_cli_options { }; // Defaults to enabled on nightly unless explicitly opted out. - unstable.build_dir_new_layout = - matches!(crate::version().release_channel.as_deref(), Some("nightly" | "dev")); + if !is_new_build_dir_layout_opt_out() { + unstable.build_dir_new_layout = + matches!(crate::version().release_channel.as_deref(), Some("nightly" | "dev")); + } return unstable; } @@ -1286,12 +1288,6 @@ impl CliUnstable { self.gitoxide = GitoxideFeatures::safe().into(); } - // NOTE: We set this before `implicitly_enable_features_if_needed` as `-Zfine-grain-locking` - // must use the new layout so that takes priority. - if is_new_build_dir_layout_opt_out() { - self.build_dir_new_layout = false; - } - self.implicitly_enable_features_if_needed(); Ok(warnings) diff --git a/tests/testsuite/build_dir.rs b/tests/testsuite/build_dir.rs index deb5bcb57cc..eceec5e3666 100644 --- a/tests/testsuite/build_dir.rs +++ b/tests/testsuite/build_dir.rs @@ -1430,9 +1430,9 @@ fn new_layout_opt_out_nightly() { ) .build(); - p.cargo("-Zbuild-dir-new-layout build") + p.cargo("build") .env("__CARGO_TEMPORARY_BUILD_DIR_NEW_LAYOUT_OPT_OUT", "1") - .masquerade_as_nightly_cargo(&["new build-dir layout"]) + .masquerade_as_nightly_cargo(&["new build-dir layout enabled by default on nightly"]) .enable_mac_dsym() .run();