@@ -215,6 +215,7 @@ pub(crate) fn run_tests(
215
215
dirs : & Dirs ,
216
216
channel : & str ,
217
217
sysroot_kind : SysrootKind ,
218
+ use_unstable_features : bool ,
218
219
cg_clif_dylib : & Path ,
219
220
bootstrap_host_compiler : & Compiler ,
220
221
target_triple : String ,
@@ -232,6 +233,7 @@ pub(crate) fn run_tests(
232
233
let runner = TestRunner :: new (
233
234
dirs. clone ( ) ,
234
235
target_compiler,
236
+ use_unstable_features,
235
237
bootstrap_host_compiler. triple == target_triple,
236
238
) ;
237
239
@@ -260,6 +262,7 @@ pub(crate) fn run_tests(
260
262
let runner = TestRunner :: new (
261
263
dirs. clone ( ) ,
262
264
target_compiler,
265
+ use_unstable_features,
263
266
bootstrap_host_compiler. triple == target_triple,
264
267
) ;
265
268
@@ -280,12 +283,18 @@ pub(crate) fn run_tests(
280
283
struct TestRunner {
281
284
is_native : bool ,
282
285
jit_supported : bool ,
286
+ use_unstable_features : bool ,
283
287
dirs : Dirs ,
284
288
target_compiler : Compiler ,
285
289
}
286
290
287
291
impl TestRunner {
288
- fn new ( dirs : Dirs , mut target_compiler : Compiler , is_native : bool ) -> Self {
292
+ fn new (
293
+ dirs : Dirs ,
294
+ mut target_compiler : Compiler ,
295
+ use_unstable_features : bool ,
296
+ is_native : bool ,
297
+ ) -> Self {
289
298
if let Ok ( rustflags) = env:: var ( "RUSTFLAGS" ) {
290
299
target_compiler. rustflags . push ( ' ' ) ;
291
300
target_compiler. rustflags . push_str ( & rustflags) ;
@@ -300,11 +309,12 @@ impl TestRunner {
300
309
target_compiler. rustflags . push_str ( " -Clink-arg=-undefined -Clink-arg=dynamic_lookup" ) ;
301
310
}
302
311
303
- let jit_supported = is_native
312
+ let jit_supported = use_unstable_features
313
+ && is_native
304
314
&& target_compiler. triple . contains ( "x86_64" )
305
315
&& !target_compiler. triple . contains ( "windows" ) ;
306
316
307
- Self { is_native, jit_supported, dirs, target_compiler }
317
+ Self { is_native, jit_supported, use_unstable_features , dirs, target_compiler }
308
318
}
309
319
310
320
fn run_testsuite ( & self , tests : & [ TestCase ] ) {
@@ -323,10 +333,24 @@ impl TestRunner {
323
333
match * cmd {
324
334
TestCaseCmd :: Custom { func } => func ( self ) ,
325
335
TestCaseCmd :: BuildLib { source, crate_types } => {
326
- self . run_rustc ( [ source, "--crate-type" , crate_types] ) ;
336
+ if self . use_unstable_features {
337
+ self . run_rustc ( [ source, "--crate-type" , crate_types] ) ;
338
+ } else {
339
+ self . run_rustc ( [
340
+ source,
341
+ "--crate-type" ,
342
+ crate_types,
343
+ "--cfg" ,
344
+ "no_unstable_features" ,
345
+ ] ) ;
346
+ }
327
347
}
328
348
TestCaseCmd :: BuildBinAndRun { source, args } => {
329
- self . run_rustc ( [ source] ) ;
349
+ if self . use_unstable_features {
350
+ self . run_rustc ( [ source] ) ;
351
+ } else {
352
+ self . run_rustc ( [ source, "--cfg" , "no_unstable_features" ] ) ;
353
+ }
330
354
self . run_out_command (
331
355
source. split ( '/' ) . last ( ) . unwrap ( ) . split ( '.' ) . next ( ) . unwrap ( ) ,
332
356
args,
0 commit comments