@@ -128,7 +128,7 @@ fn setup() -> Option<Setup> {
128128 } )
129129}
130130
131- fn enable_build_std ( e : & mut Execs , setup : & Setup , arg : Option < & str > ) {
131+ fn enable_build_std ( e : & mut Execs , setup : & Setup ) {
132132 // First up, force Cargo to use our "mock sysroot" which mimics what
133133 // libstd looks like upstream.
134134 let root = paths:: root ( ) ;
@@ -142,12 +142,6 @@ fn enable_build_std(e: &mut Execs, setup: &Setup, arg: Option<&str>) {
142142 . join ( "tests/testsuite/mock-std" ) ;
143143 e. env ( "__CARGO_TESTS_ONLY_SRC_ROOT" , & root) ;
144144
145- // Actually enable `-Zbuild-std` for now
146- let arg = match arg {
147- Some ( s) => format ! ( "-Zbuild-std={}" , s) ,
148- None => "-Zbuild-std" . to_string ( ) ,
149- } ;
150- e. arg ( arg) ;
151145 e. masquerade_as_nightly_cargo ( ) ;
152146
153147 // We do various shenanigans to ensure our "mock sysroot" actually links
@@ -181,12 +175,14 @@ trait BuildStd: Sized {
181175
182176impl BuildStd for Execs {
183177 fn build_std ( & mut self , setup : & Setup ) -> & mut Self {
184- enable_build_std ( self , setup, None ) ;
178+ enable_build_std ( self , setup) ;
179+ self . arg ( "-Zbuild-std" ) ;
185180 self
186181 }
187182
188183 fn build_std_arg ( & mut self , setup : & Setup , arg : & str ) -> & mut Self {
189- enable_build_std ( self , setup, Some ( arg) ) ;
184+ enable_build_std ( self , setup) ;
185+ self . arg ( format ! ( "-Zbuild-std={}" , arg) ) ;
190186 self
191187 }
192188
@@ -604,3 +600,35 @@ fn ignores_incremental() {
604600 . unwrap( )
605601 . starts_with( "foo-" ) ) ;
606602}
603+
604+ #[ cargo_test]
605+ fn cargo_config_injects_compiler_builtins ( ) {
606+ let setup = match setup ( ) {
607+ Some ( s) => s,
608+ None => return ,
609+ } ;
610+ let p = project ( )
611+ . file (
612+ "src/lib.rs" ,
613+ r#"
614+ #![no_std]
615+ pub fn foo() {
616+ assert_eq!(u8::MIN, 0);
617+ }
618+ "# ,
619+ )
620+ . file (
621+ ".cargo/config.toml" ,
622+ r#"
623+ [unstable]
624+ build-std = ['core']
625+ "# ,
626+ )
627+ . build ( ) ;
628+ let mut build = p. cargo ( "build -v --lib" ) ;
629+ enable_build_std ( & mut build, & setup) ;
630+ build
631+ . target_host ( )
632+ . with_stderr_does_not_contain ( "[..]libstd[..]" )
633+ . run ( ) ;
634+ }
0 commit comments