@@ -214,6 +214,7 @@ pub(crate) fn run_tests(
214214 dirs : & Dirs ,
215215 channel : & str ,
216216 sysroot_kind : SysrootKind ,
217+ use_unstable_features : bool ,
217218 cg_clif_dylib : & CodegenBackend ,
218219 bootstrap_host_compiler : & Compiler ,
219220 rustup_toolchain_name : Option < & str > ,
@@ -233,6 +234,7 @@ pub(crate) fn run_tests(
233234 let runner = TestRunner :: new (
234235 dirs. clone ( ) ,
235236 target_compiler,
237+ use_unstable_features,
236238 bootstrap_host_compiler. triple == target_triple,
237239 ) ;
238240
@@ -262,6 +264,7 @@ pub(crate) fn run_tests(
262264 let runner = TestRunner :: new (
263265 dirs. clone ( ) ,
264266 target_compiler,
267+ use_unstable_features,
265268 bootstrap_host_compiler. triple == target_triple,
266269 ) ;
267270
@@ -282,12 +285,18 @@ pub(crate) fn run_tests(
282285struct TestRunner {
283286 is_native : bool ,
284287 jit_supported : bool ,
288+ use_unstable_features : bool ,
285289 dirs : Dirs ,
286290 target_compiler : Compiler ,
287291}
288292
289293impl TestRunner {
290- fn new ( dirs : Dirs , mut target_compiler : Compiler , is_native : bool ) -> Self {
294+ fn new (
295+ dirs : Dirs ,
296+ mut target_compiler : Compiler ,
297+ use_unstable_features : bool ,
298+ is_native : bool ,
299+ ) -> Self {
291300 if let Ok ( rustflags) = env:: var ( "RUSTFLAGS" ) {
292301 target_compiler. rustflags . push ( ' ' ) ;
293302 target_compiler. rustflags . push_str ( & rustflags) ;
@@ -302,11 +311,12 @@ impl TestRunner {
302311 target_compiler. rustflags . push_str ( " -Clink-arg=-undefined -Clink-arg=dynamic_lookup" ) ;
303312 }
304313
305- let jit_supported = is_native
314+ let jit_supported = use_unstable_features
315+ && is_native
306316 && target_compiler. triple . contains ( "x86_64" )
307317 && !target_compiler. triple . contains ( "windows" ) ;
308318
309- Self { is_native, jit_supported, dirs, target_compiler }
319+ Self { is_native, jit_supported, use_unstable_features , dirs, target_compiler }
310320 }
311321
312322 fn run_testsuite ( & self , tests : & [ TestCase ] ) {
@@ -325,10 +335,24 @@ impl TestRunner {
325335 match * cmd {
326336 TestCaseCmd :: Custom { func } => func ( self ) ,
327337 TestCaseCmd :: BuildLib { source, crate_types } => {
328- self . run_rustc ( [ source, "--crate-type" , crate_types] ) ;
338+ if self . use_unstable_features {
339+ self . run_rustc ( [ source, "--crate-type" , crate_types] ) ;
340+ } else {
341+ self . run_rustc ( [
342+ source,
343+ "--crate-type" ,
344+ crate_types,
345+ "--cfg" ,
346+ "no_unstable_features" ,
347+ ] ) ;
348+ }
329349 }
330350 TestCaseCmd :: BuildBinAndRun { source, args } => {
331- self . run_rustc ( [ source] ) ;
351+ if self . use_unstable_features {
352+ self . run_rustc ( [ source] ) ;
353+ } else {
354+ self . run_rustc ( [ source, "--cfg" , "no_unstable_features" ] ) ;
355+ }
332356 self . run_out_command (
333357 source. split ( '/' ) . last ( ) . unwrap ( ) . split ( '.' ) . next ( ) . unwrap ( ) ,
334358 args,
0 commit comments