@@ -127,6 +127,7 @@ use std::str::FromStr;
127127use anyhow:: { Error , bail} ;
128128use cargo_util:: ProcessBuilder ;
129129use serde:: { Deserialize , Serialize } ;
130+ use tracing:: debug;
130131
131132use crate :: GlobalContext ;
132133use crate :: core:: resolver:: ResolveBehavior ;
@@ -861,6 +862,7 @@ unstable_cli_options!(
861862 dual_proc_macros: bool = ( "Build proc-macros for both the host and the target" ) ,
862863 feature_unification: bool = ( "Enable new feature unification modes in workspaces" ) ,
863864 features: Option <Vec <String >>,
865+ fine_grain_locking: bool = ( "Use fine grain locking instead of locking the entire build cache" ) ,
864866 fix_edition: Option <FixEdition > = ( "Permanently unstable edition migration helper" ) ,
865867 gc: bool = ( "Track cache usage and \" garbage collect\" unused files" ) ,
866868 #[ serde( deserialize_with = "deserialize_git_features" ) ]
@@ -1241,6 +1243,9 @@ impl CliUnstable {
12411243 if self . gitoxide . is_none ( ) && cargo_use_gitoxide_instead_of_git2 ( ) {
12421244 self . gitoxide = GitoxideFeatures :: safe ( ) . into ( ) ;
12431245 }
1246+
1247+ self . implicitly_enable_features_if_needed ( ) ;
1248+
12441249 Ok ( warnings)
12451250 }
12461251
@@ -1379,6 +1384,7 @@ impl CliUnstable {
13791384 "direct-minimal-versions" => self . direct_minimal_versions = parse_empty ( k, v) ?,
13801385 "dual-proc-macros" => self . dual_proc_macros = parse_empty ( k, v) ?,
13811386 "feature-unification" => self . feature_unification = parse_empty ( k, v) ?,
1387+ "fine-grain-locking" => self . fine_grain_locking = parse_empty ( k, v) ?,
13821388 "fix-edition" => {
13831389 let fe = v
13841390 . ok_or_else ( || anyhow:: anyhow!( "-Zfix-edition expected a value" ) ) ?
@@ -1510,6 +1516,13 @@ impl CliUnstable {
15101516 ) ;
15111517 }
15121518 }
1519+
1520+ fn implicitly_enable_features_if_needed ( & mut self ) {
1521+ if self . fine_grain_locking && !self . build_dir_new_layout {
1522+ debug ! ( "-Zbuild-dir-new-layout implicitly enabled by -Zfine-grain-locking" ) ;
1523+ self . build_dir_new_layout = true ;
1524+ }
1525+ }
15131526}
15141527
15151528/// Returns the current release channel ("stable", "beta", "nightly", "dev").
0 commit comments