diff --git a/src/workspace/features.rs b/src/workspace/features.rs index 6a270d9af9e..8d29ecf4c43 100644 --- a/src/workspace/features.rs +++ b/src/workspace/features.rs @@ -826,7 +826,7 @@ macro_rules! unstable_cli_options { /// Cargo, like `rustc`, accepts a suite of `-Z` flags which are intended for /// gating unstable functionality to Cargo. These flags are only available on /// the nightly channel of Cargo. - #[derive(Default, Debug, Deserialize)] + #[derive(Debug, Deserialize)] #[serde(default, rename_all = "kebab-case")] pub struct CliUnstable { $( @@ -842,6 +842,21 @@ macro_rules! unstable_cli_options { fields } } + impl Default for CliUnstable { + fn default() -> Self { + let mut unstable = Self { + $( + $element: Default::default() + ),* + }; + + // Defaults to enabled on nightly unless explicitly opted out. + unstable.build_dir_new_layout = + matches!(crate::version().release_channel.as_deref(), Some("nightly" | "dev")); + + return unstable; + } + } #[cfg(test)] mod test {