@@ -399,7 +399,9 @@ fn optgroups() -> getopts::Options {
399
399
. optopt ( "" , "format" , "Configure formatting of output:
400
400
pretty = Print verbose output;
401
401
terse = Display one character per test;
402
- json = Output a json document" , "pretty|terse|json" ) ;
402
+ json = Output a json document" , "pretty|terse|json" )
403
+ . optopt ( "Z" , "" , "Enable nightly-only flags:
404
+ unstable-options = Allow use of experimental features" , "unstable-options" ) ;
403
405
return opts
404
406
}
405
407
@@ -435,15 +437,41 @@ Test Attributes:
435
437
usage = options. usage( & message) ) ;
436
438
}
437
439
440
+ // FIXME: Copied from libsyntax until linkage errors are resolved.
441
+ fn is_nightly ( ) -> bool {
442
+ // Whether this is a feature-staged build, i.e. on the beta or stable channel
443
+ let disable_unstable_features = option_env ! ( "CFG_DISABLE_UNSTABLE_FEATURES" ) . is_some ( ) ;
444
+ // Whether we should enable unstable features for bootstrapping
445
+ let bootstrap = env:: var ( "RUSTC_BOOTSTRAP" ) . is_ok ( ) ;
446
+
447
+ bootstrap || !disable_unstable_features
448
+ }
449
+
438
450
// Parses command line arguments into test options
439
451
pub fn parse_opts ( args : & [ String ] ) -> Option < OptRes > {
452
+ let mut allow_unstable = false ;
440
453
let opts = optgroups ( ) ;
441
454
let args = args. get ( 1 ..) . unwrap_or ( args) ;
442
455
let matches = match opts. parse ( args) {
443
456
Ok ( m) => m,
444
457
Err ( f) => return Some ( Err ( f. to_string ( ) ) ) ,
445
458
} ;
446
459
460
+ if let Some ( opt) = matches. opt_str ( "Z" ) {
461
+ if !is_nightly ( ) {
462
+ return Some ( Err ( "the option `Z` is only accepted on the nightly compiler" . into ( ) ) ) ;
463
+ }
464
+
465
+ match & * opt {
466
+ "unstable-options" => {
467
+ allow_unstable = true ;
468
+ }
469
+ _ => {
470
+ return Some ( Err ( "Unrecognized option to `Z`" . into ( ) ) ) ;
471
+ }
472
+ }
473
+ } ;
474
+
447
475
if matches. opt_present ( "h" ) {
448
476
usage ( & args[ 0 ] , & opts) ;
449
477
return None ;
@@ -504,7 +532,13 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
504
532
None if quiet => OutputFormat :: Terse ,
505
533
Some ( "pretty" ) | None => OutputFormat :: Pretty ,
506
534
Some ( "terse" ) => OutputFormat :: Terse ,
507
- Some ( "json" ) => OutputFormat :: Json ,
535
+ Some ( "json" ) => {
536
+ if !allow_unstable {
537
+ return Some (
538
+ Err ( "The \" json\" format is only accepted on the nightly compiler" . into ( ) ) ) ;
539
+ }
540
+ OutputFormat :: Json
541
+ } ,
508
542
509
543
Some ( v) => {
510
544
return Some ( Err ( format ! ( "argument for --format must be pretty, terse, or json (was \
0 commit comments