@@ -450,8 +450,19 @@ Test Attributes:
450
450
usage = options. usage( & message) ) ;
451
451
}
452
452
453
+ // FIXME: Copied from libsyntax until linkage errors are resolved.
454
+ fn allow_unstable ( ) -> bool {
455
+ // Whether this is a feature-staged build, i.e. on the beta or stable channel
456
+ let disable_unstable_features = option_env ! ( "CFG_DISABLE_UNSTABLE_FEATURES" ) . is_some ( ) ;
457
+ // Whether we should enable unstable features for bootstrapping
458
+ let bootstrap = env:: var ( "RUSTC_BOOTSTRAP" ) . is_ok ( ) ;
459
+
460
+ bootstrap || !disable_unstable_features
461
+ }
462
+
453
463
// Parses command line arguments into test options
454
464
pub fn parse_opts ( args : & [ String ] ) -> Option < OptRes > {
465
+ let allow_unstable = allow_unstable ( ) ;
455
466
let opts = optgroups ( ) ;
456
467
let args = args. get ( 1 ..) . unwrap_or ( args) ;
457
468
let matches = match opts. parse ( args) {
@@ -519,7 +530,13 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
519
530
None if quiet => OutputFormat :: Terse ,
520
531
Some ( "pretty" ) | None => OutputFormat :: Pretty ,
521
532
Some ( "terse" ) => OutputFormat :: Terse ,
522
- Some ( "json" ) => OutputFormat :: Json ,
533
+ Some ( "json" ) => {
534
+ if !allow_unstable {
535
+ return Some (
536
+ Err ( "The \" json\" format is only accepted on the nightly compiler" . into ( ) ) ) ;
537
+ }
538
+ OutputFormat :: Json
539
+ } ,
523
540
524
541
Some ( v) => {
525
542
return Some ( Err ( format ! ( "argument for --format must be pretty, terse, or json (was \
0 commit comments