@@ -450,8 +450,19 @@ Test Attributes:
450450 usage = options. usage( & message) ) ;
451451}
452452
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+
453463// Parses command line arguments into test options
454464pub fn parse_opts ( args : & [ String ] ) -> Option < OptRes > {
465+ let allow_unstable = allow_unstable ( ) ;
455466 let opts = optgroups ( ) ;
456467 let args = args. get ( 1 ..) . unwrap_or ( args) ;
457468 let matches = match opts. parse ( args) {
@@ -519,7 +530,13 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
519530 None if quiet => OutputFormat :: Terse ,
520531 Some ( "pretty" ) | None => OutputFormat :: Pretty ,
521532 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+ } ,
523540
524541 Some ( v) => {
525542 return Some ( Err ( format ! ( "argument for --format must be pretty, terse, or json (was \
0 commit comments