From 4e46eee110b739ab415affc8f9b524d6b4be8554 Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Thu, 3 Mar 2016 10:06:09 +0100 Subject: [PATCH] Hide gated cfg attributes from the output of `--print cfg` Gated cfg attributes are not available on the stable and beta release channels, therefore they should not be presented to users of those channels in order to avoid confusion. --- src/librustc_driver/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 0a3ebcb4ca1eb..da565856a9f5a 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -94,7 +94,7 @@ use syntax::errors; use syntax::errors::emitter::Emitter; use syntax::diagnostics; use syntax::parse::token; -use syntax::feature_gate::UnstableFeatures; +use syntax::feature_gate::{GatedCfg, UnstableFeatures}; #[cfg(test)] pub mod test; @@ -567,7 +567,16 @@ impl RustcDefaultCalls { PrintRequest::Cfg => { let mut cfg = config::build_configuration(&sess); target_features::add_configuration(&mut cfg, &sess); + + let allow_unstable_cfg = match get_unstable_features_setting() { + UnstableFeatures::Disallow => false, + _ => true, + }; + for cfg in cfg { + if !allow_unstable_cfg && GatedCfg::gate(&*cfg).is_some() { + continue; + } match cfg.node { ast::MetaItemKind::Word(ref word) => println!("{}", word), ast::MetaItemKind::NameValue(ref name, ref value) => {