@@ -1401,19 +1401,28 @@ impl<'a> Builder<'a> {
14011401            rustflags. arg ( "-Zunstable-options" ) ; 
14021402        } 
14031403
1404-         // Enable cfg checking of cargo features for everything but std and also enable cfg 
1405-         // checking of names and values. 
1404+         // #[cfg(bootstrap)] should remove every code path where it's false 
1405+         const  USE_NEW_CHECK_CFG_SYNTAX :  bool  = false ; 
1406+ 
1407+         // Enable compile-time checking of `cfg` names, values and Cargo `features`. 
14061408        // 
14071409        // Note: `std`, `alloc` and `core` imports some dependencies by #[path] (like 
14081410        // backtrace, core_simd, std_float, ...), those dependencies have their own 
14091411        // features but cargo isn't involved in the #[path] process and so cannot pass the 
14101412        // complete list of features, so for that reason we don't enable checking of 
14111413        // features for std crates. 
1412-         cargo. arg ( if  mode != Mode :: Std  { 
1413-             "-Zcheck-cfg=names,values,output,features" 
1414+         if  USE_NEW_CHECK_CFG_SYNTAX  { 
1415+             cargo. arg ( "-Zcheck-cfg" ) ; 
1416+             if  mode == Mode :: Std  { 
1417+                 rustflags. arg ( "--check-cfg=cfg(feature,values(any()))" ) ; 
1418+             } 
14141419        }  else  { 
1415-             "-Zcheck-cfg=names,values,output" 
1416-         } ) ; 
1420+             cargo. arg ( if  mode != Mode :: Std  { 
1421+                 "-Zcheck-cfg=names,values,output,features" 
1422+             }  else  { 
1423+                 "-Zcheck-cfg=names,values,output" 
1424+             } ) ; 
1425+         } 
14171426
14181427        // Add extra cfg not defined in/by rustc 
14191428        // 
@@ -1433,7 +1442,12 @@ impl<'a> Builder<'a> {
14331442                        . collect :: < String > ( ) , 
14341443                    None  => String :: new ( ) , 
14351444                } ; 
1436-                 rustflags. arg ( & format ! ( "--check-cfg=values({name}{values})" ) ) ; 
1445+                 if  USE_NEW_CHECK_CFG_SYNTAX  { 
1446+                     let  values = values. strip_prefix ( "," ) . unwrap_or ( & values) ;  // remove the first `,` 
1447+                     rustflags. arg ( & format ! ( "--check-cfg=cfg({name},values({values}))" ) ) ; 
1448+                 }  else  { 
1449+                     rustflags. arg ( & format ! ( "--check-cfg=values({name}{values})" ) ) ; 
1450+                 } 
14371451            } 
14381452        } 
14391453
@@ -1449,7 +1463,11 @@ impl<'a> Builder<'a> {
14491463        // We also declare that the flag is expected, which we need to do to not 
14501464        // get warnings about it being unexpected. 
14511465        hostflags. arg ( "-Zunstable-options" ) ; 
1452-         hostflags. arg ( "--check-cfg=values(bootstrap)" ) ; 
1466+         if  USE_NEW_CHECK_CFG_SYNTAX  { 
1467+             hostflags. arg ( "--check-cfg=cfg(bootstrap)" ) ; 
1468+         }  else  { 
1469+             hostflags. arg ( "--check-cfg=values(bootstrap)" ) ; 
1470+         } 
14531471
14541472        // FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`, 
14551473        // but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See 
0 commit comments