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.
This commit is contained in:
Andrea Canciani 2016-03-03 10:06:09 +01:00
parent c984cbd939
commit 4e46eee110

View file

@ -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) => {