Added stmt_expr_attribute feature gate

This commit is contained in:
Marvin Löbel
2015-11-24 14:56:20 +01:00
parent c56b47ab8c
commit 296c3613ca
11 changed files with 469 additions and 63 deletions

View File

@@ -17,7 +17,7 @@ use codemap::{CodeMap, Span, ExpnId, ExpnInfo, NO_EXPANSION};
use ext;
use ext::expand;
use ext::tt::macro_rules;
use feature_gate::GatedCfg;
use feature_gate::GatedCfgAttr;
use parse;
use parse::parser;
use parse::token;
@@ -572,7 +572,7 @@ pub struct ExtCtxt<'a> {
pub backtrace: ExpnId,
pub ecfg: expand::ExpansionConfig<'a>,
pub crate_root: Option<&'static str>,
pub feature_gated_cfgs: &'a mut Vec<GatedCfg>,
pub feature_gated_cfgs: &'a mut Vec<GatedCfgAttr>,
pub mod_path: Vec<ast::Ident> ,
pub exported_macros: Vec<ast::MacroDef>,
@@ -584,7 +584,7 @@ pub struct ExtCtxt<'a> {
impl<'a> ExtCtxt<'a> {
pub fn new(parse_sess: &'a parse::ParseSess, cfg: ast::CrateConfig,
ecfg: expand::ExpansionConfig<'a>,
feature_gated_cfgs: &'a mut Vec<GatedCfg>) -> ExtCtxt<'a> {
feature_gated_cfgs: &'a mut Vec<GatedCfgAttr>) -> ExtCtxt<'a> {
let env = initial_syntax_expander_table(&ecfg);
ExtCtxt {
parse_sess: parse_sess,

View File

@@ -20,6 +20,7 @@ use ext::build::AstBuilder;
use attr;
use attr::*;
use parse::token;
use config::CfgDiagReal;
pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
sp: Span,
@@ -33,7 +34,12 @@ pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
return DummyResult::expr(sp);
}
let matches_cfg = attr::cfg_matches(&cx.parse_sess.span_diagnostic, &cx.cfg, &cfg,
cx.feature_gated_cfgs);
let matches_cfg = {
let mut diag = CfgDiagReal {
diag: &cx.parse_sess.span_diagnostic,
feature_gated_cfgs: cx.feature_gated_cfgs,
};
attr::cfg_matches(&cx.cfg, &cfg, &mut diag)
};
MacEager::expr(cx.expr_bool(sp, matches_cfg))
}

View File

@@ -21,7 +21,7 @@ use attr::{AttrMetaMethods, WithAttrs};
use codemap;
use codemap::{Span, Spanned, ExpnInfo, NameAndSpan, MacroBang, MacroAttribute};
use ext::base::*;
use feature_gate::{self, Features, GatedCfg};
use feature_gate::{self, Features, GatedCfgAttr};
use fold;
use fold::*;
use util::move_map::MoveMap;
@@ -586,7 +586,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE
// also, don't forget to expand the init:
init: init.map(|e| fld.fold_expr(e)),
span: span,
attrs: attrs
attrs: fold::fold_thin_attrs(attrs, fld),
}
});
SmallVector::one(P(Spanned {
@@ -1280,7 +1280,7 @@ pub fn expand_crate<'feat>(parse_sess: &parse::ParseSess,
// these are the macros being imported to this crate:
imported_macros: Vec<ast::MacroDef>,
user_exts: Vec<NamedSyntaxExtension>,
feature_gated_cfgs: &mut Vec<GatedCfg>,
feature_gated_cfgs: &mut Vec<GatedCfgAttr>,
c: Crate) -> (Crate, HashSet<Name>) {
let mut cx = ExtCtxt::new(parse_sess, c.config.clone(), cfg,
feature_gated_cfgs);