@@ -214,6 +214,7 @@ pub(crate) fn run_tests(
214
214
dirs : & Dirs ,
215
215
channel : & str ,
216
216
sysroot_kind : SysrootKind ,
217
+ use_unstable_features : bool ,
217
218
cg_clif_dylib : & CodegenBackend ,
218
219
bootstrap_host_compiler : & Compiler ,
219
220
rustup_toolchain_name : Option < & str > ,
@@ -233,6 +234,7 @@ pub(crate) fn run_tests(
233
234
let runner = TestRunner :: new (
234
235
dirs. clone ( ) ,
235
236
target_compiler,
237
+ use_unstable_features,
236
238
bootstrap_host_compiler. triple == target_triple,
237
239
) ;
238
240
@@ -262,6 +264,7 @@ pub(crate) fn run_tests(
262
264
let runner = TestRunner :: new (
263
265
dirs. clone ( ) ,
264
266
target_compiler,
267
+ use_unstable_features,
265
268
bootstrap_host_compiler. triple == target_triple,
266
269
) ;
267
270
@@ -282,12 +285,18 @@ pub(crate) fn run_tests(
282
285
struct TestRunner {
283
286
is_native : bool ,
284
287
jit_supported : bool ,
288
+ use_unstable_features : bool ,
285
289
dirs : Dirs ,
286
290
target_compiler : Compiler ,
287
291
}
288
292
289
293
impl 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 {
291
300
if let Ok ( rustflags) = env:: var ( "RUSTFLAGS" ) {
292
301
target_compiler. rustflags . push ( ' ' ) ;
293
302
target_compiler. rustflags . push_str ( & rustflags) ;
@@ -302,11 +311,12 @@ impl TestRunner {
302
311
target_compiler. rustflags . push_str ( " -Clink-arg=-undefined -Clink-arg=dynamic_lookup" ) ;
303
312
}
304
313
305
- let jit_supported = is_native
314
+ let jit_supported = use_unstable_features
315
+ && is_native
306
316
&& target_compiler. triple . contains ( "x86_64" )
307
317
&& !target_compiler. triple . contains ( "windows" ) ;
308
318
309
- Self { is_native, jit_supported, dirs, target_compiler }
319
+ Self { is_native, jit_supported, use_unstable_features , dirs, target_compiler }
310
320
}
311
321
312
322
fn run_testsuite ( & self , tests : & [ TestCase ] ) {
@@ -325,10 +335,24 @@ impl TestRunner {
325
335
match * cmd {
326
336
TestCaseCmd :: Custom { func } => func ( self ) ,
327
337
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
+ }
329
349
}
330
350
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
+ }
332
356
self . run_out_command (
333
357
source. split ( '/' ) . last ( ) . unwrap ( ) . split ( '.' ) . next ( ) . unwrap ( ) ,
334
358
args,
0 commit comments