Skip to content

Commit 4e46eee

Browse files
committed
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.
1 parent c984cbd commit 4e46eee

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/librustc_driver/lib.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ use syntax::errors;
9494
use syntax::errors::emitter::Emitter;
9595
use syntax::diagnostics;
9696
use syntax::parse::token;
97-
use syntax::feature_gate::UnstableFeatures;
97+
use syntax::feature_gate::{GatedCfg, UnstableFeatures};
9898

9999
#[cfg(test)]
100100
pub mod test;
@@ -567,7 +567,16 @@ impl RustcDefaultCalls {
567567
PrintRequest::Cfg => {
568568
let mut cfg = config::build_configuration(&sess);
569569
target_features::add_configuration(&mut cfg, &sess);
570+
571+
let allow_unstable_cfg = match get_unstable_features_setting() {
572+
UnstableFeatures::Disallow => false,
573+
_ => true,
574+
};
575+
570576
for cfg in cfg {
577+
if !allow_unstable_cfg && GatedCfg::gate(&*cfg).is_some() {
578+
continue;
579+
}
571580
match cfg.node {
572581
ast::MetaItemKind::Word(ref word) => println!("{}", word),
573582
ast::MetaItemKind::NameValue(ref name, ref value) => {

0 commit comments

Comments
 (0)