@@ -1373,6 +1373,44 @@ impl Config {
1373
1373
Self :: parse_inner ( flags, Self :: get_toml)
1374
1374
}
1375
1375
1376
+ fn handle_profiles_recursively (
1377
+ & self ,
1378
+ get_toml : impl Fn ( & Path ) -> Result < TomlConfig , toml:: de:: Error > ,
1379
+ toml : & mut TomlConfig ,
1380
+ ) {
1381
+ if let Some ( profile) = & toml. profile {
1382
+ let mut include_path = PathBuf :: from ( format ! ( "{profile}.toml" ) ) ;
1383
+
1384
+ if !include_path. exists ( ) {
1385
+ // Allows creating alias for profile names, allowing
1386
+ // profiles to be renamed while maintaining back compatibility
1387
+ // Keep in sync with `profile_aliases` in bootstrap.py
1388
+ let profile_aliases = HashMap :: from ( [ ( "user" , "dist" ) ] ) ;
1389
+ let profile = match profile_aliases. get ( profile. as_str ( ) ) {
1390
+ Some ( alias) => alias,
1391
+ None => profile. as_str ( ) ,
1392
+ } ;
1393
+
1394
+ include_path = self
1395
+ . src
1396
+ . join ( "src/bootstrap/defaults" )
1397
+ . join ( format ! ( "bootstrap.{profile}.toml" ) ) ;
1398
+ }
1399
+
1400
+ let mut included_toml = get_toml ( & include_path) . unwrap_or_else ( |e| {
1401
+ eprintln ! (
1402
+ "ERROR: Failed to parse default config profile at '{}': {e}" ,
1403
+ include_path. display( )
1404
+ ) ;
1405
+ exit ! ( 2 ) ;
1406
+ } ) ;
1407
+
1408
+ self . handle_profiles_recursively ( get_toml, & mut included_toml) ;
1409
+
1410
+ toml. merge ( included_toml, ReplaceOpt :: IgnoreDuplicate ) ;
1411
+ }
1412
+ }
1413
+
1376
1414
#[ cfg_attr(
1377
1415
feature = "tracing" ,
1378
1416
instrument(
@@ -1552,35 +1590,7 @@ impl Config {
1552
1590
toml. profile = Some ( "dist" . into ( ) ) ;
1553
1591
}
1554
1592
1555
- if let Some ( profile) = & toml. profile {
1556
- let mut include_path = PathBuf :: from ( format ! ( "{profile}.toml" ) ) ;
1557
-
1558
- if !include_path. exists ( ) {
1559
- // Allows creating alias for profile names, allowing
1560
- // profiles to be renamed while maintaining back compatibility
1561
- // Keep in sync with `profile_aliases` in bootstrap.py
1562
- let profile_aliases = HashMap :: from ( [ ( "user" , "dist" ) ] ) ;
1563
- let profile = match profile_aliases. get ( profile. as_str ( ) ) {
1564
- Some ( alias) => alias,
1565
- None => profile. as_str ( ) ,
1566
- } ;
1567
-
1568
- include_path = config
1569
- . src
1570
- . join ( "src/bootstrap/defaults" )
1571
- . join ( format ! ( "bootstrap.{profile}.toml" ) ) ;
1572
- }
1573
-
1574
- let included_toml = get_toml ( & include_path) . unwrap_or_else ( |e| {
1575
- eprintln ! (
1576
- "ERROR: Failed to parse default config profile at '{}': {e}" ,
1577
- include_path. display( )
1578
- ) ;
1579
- exit ! ( 2 ) ;
1580
- } ) ;
1581
-
1582
- toml. merge ( included_toml, ReplaceOpt :: IgnoreDuplicate ) ;
1583
- }
1593
+ config. handle_profiles_recursively ( get_toml, & mut toml) ;
1584
1594
1585
1595
let mut override_toml = TomlConfig :: default ( ) ;
1586
1596
for option in flags. set . iter ( ) {
0 commit comments