@@ -128,7 +128,7 @@ fn setup() -> Option<Setup> {
128
128
} )
129
129
}
130
130
131
- fn enable_build_std ( e : & mut Execs , setup : & Setup , arg : Option < & str > ) {
131
+ fn enable_build_std ( e : & mut Execs , setup : & Setup ) {
132
132
// First up, force Cargo to use our "mock sysroot" which mimics what
133
133
// libstd looks like upstream.
134
134
let root = paths:: root ( ) ;
@@ -142,12 +142,6 @@ fn enable_build_std(e: &mut Execs, setup: &Setup, arg: Option<&str>) {
142
142
. join ( "tests/testsuite/mock-std" ) ;
143
143
e. env ( "__CARGO_TESTS_ONLY_SRC_ROOT" , & root) ;
144
144
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) ;
151
145
e. masquerade_as_nightly_cargo ( ) ;
152
146
153
147
// We do various shenanigans to ensure our "mock sysroot" actually links
@@ -181,12 +175,14 @@ trait BuildStd: Sized {
181
175
182
176
impl BuildStd for Execs {
183
177
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" ) ;
185
180
self
186
181
}
187
182
188
183
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) ) ;
190
186
self
191
187
}
192
188
@@ -604,3 +600,35 @@ fn ignores_incremental() {
604
600
. unwrap( )
605
601
. starts_with( "foo-" ) ) ;
606
602
}
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