about summary refs log tree commit diff
path: root/src/librustc_driver
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-11-30 01:57:53 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2019-11-30 01:57:53 +0100
commit6cab02cf149787db6c9e30ee0ceed97768bbe9aa (patch)
tree69ca7363f283a7a6be0251062f76956dfd2bc4e5 /src/librustc_driver
parent8ad4d15f3888f1339d52632d40e0a47697dd2a24 (diff)
downloadrust-6cab02cf149787db6c9e30ee0ceed97768bbe9aa.tar.gz
rust-6cab02cf149787db6c9e30ee0ceed97768bbe9aa.zip
simplify gated cfgs logic
Diffstat (limited to 'src/librustc_driver')
-rw-r--r--src/librustc_driver/lib.rs21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index 13829b842fd..22f130ed3c9 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -62,9 +62,9 @@ use std::time::Instant;
 
 use syntax::ast;
 use syntax::source_map::FileLoader;
-use syntax::feature_gate::{GatedCfg, UnstableFeatures};
-use syntax::symbol::sym;
-use syntax_pos::{DUMMY_SP, FileName};
+use syntax::feature_gate::{find_gated_cfg, UnstableFeatures};
+use syntax_pos::symbol::sym;
+use syntax_pos::FileName;
 
 pub mod pretty;
 mod args;
@@ -677,12 +677,6 @@ impl RustcDefaultCalls {
                         .is_nightly_build();
 
                     let mut cfgs = sess.parse_sess.config.iter().filter_map(|&(name, ref value)| {
-                        let gated_cfg = GatedCfg::gate(&ast::MetaItem {
-                            path: ast::Path::from_ident(ast::Ident::with_dummy_span(name)),
-                            kind: ast::MetaItemKind::Word,
-                            span: DUMMY_SP,
-                        });
-
                         // Note that crt-static is a specially recognized cfg
                         // directive that's printed out here as part of
                         // rust-lang/rust#37406, but in general the
@@ -693,10 +687,11 @@ impl RustcDefaultCalls {
                         // through to build scripts.
                         let value = value.as_ref().map(|s| s.as_str());
                         let value = value.as_ref().map(|s| s.as_ref());
-                        if name != sym::target_feature || value != Some("crt-static") {
-                            if !allow_unstable_cfg && gated_cfg.is_some() {
-                                return None
-                            }
+                        if (name != sym::target_feature || value != Some("crt-static"))
+                            && !allow_unstable_cfg
+                            && find_gated_cfg(|cfg_sym| cfg_sym == name).is_some()
+                        {
+                            return None;
                         }
 
                         if let Some(value) = value {