Simplify gated cfg checking
This commit is contained in:
parent
7aba683c76
commit
2cd6ccf0b1
11 changed files with 113 additions and 218 deletions
|
|
@ -18,7 +18,6 @@ use errors::DiagnosticBuilder;
|
|||
use ext;
|
||||
use ext::expand;
|
||||
use ext::tt::macro_rules;
|
||||
use feature_gate::GatedCfgAttr;
|
||||
use parse;
|
||||
use parse::parser;
|
||||
use parse::token;
|
||||
|
|
@ -556,7 +555,6 @@ 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<GatedCfgAttr>,
|
||||
pub loader: &'a mut MacroLoader,
|
||||
|
||||
pub mod_path: Vec<ast::Ident> ,
|
||||
|
|
@ -573,7 +571,6 @@ 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<GatedCfgAttr>,
|
||||
loader: &'a mut MacroLoader)
|
||||
-> ExtCtxt<'a> {
|
||||
let env = initial_syntax_expander_table(&ecfg);
|
||||
|
|
@ -584,7 +581,6 @@ impl<'a> ExtCtxt<'a> {
|
|||
mod_path: Vec::new(),
|
||||
ecfg: ecfg,
|
||||
crate_root: None,
|
||||
feature_gated_cfgs: feature_gated_cfgs,
|
||||
exported_macros: Vec::new(),
|
||||
loader: loader,
|
||||
syntax_env: env,
|
||||
|
|
|
|||
|
|
@ -998,10 +998,12 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
}
|
||||
|
||||
fn strip_unconfigured(&mut self) -> StripUnconfigured {
|
||||
StripUnconfigured::new(&self.cx.cfg,
|
||||
self.cx.ecfg.should_test,
|
||||
&self.cx.parse_sess.span_diagnostic,
|
||||
self.cx.feature_gated_cfgs)
|
||||
StripUnconfigured {
|
||||
config: &self.cx.cfg,
|
||||
should_test: self.cx.ecfg.should_test,
|
||||
sess: self.cx.parse_sess,
|
||||
features: self.cx.ecfg.features,
|
||||
}
|
||||
}
|
||||
|
||||
fn load_macros<T: MacroGenerable>(&mut self, node: &T) {
|
||||
|
|
@ -1331,8 +1333,8 @@ mod tests {
|
|||
src,
|
||||
Vec::new(), &sess).unwrap();
|
||||
// should fail:
|
||||
let (mut gated_cfgs, mut loader) = (vec![], DummyMacroLoader);
|
||||
let ecx = ExtCtxt::new(&sess, vec![], test_ecfg(), &mut gated_cfgs, &mut loader);
|
||||
let mut loader = DummyMacroLoader;
|
||||
let ecx = ExtCtxt::new(&sess, vec![], test_ecfg(), &mut loader);
|
||||
expand_crate(ecx, vec![], crate_ast);
|
||||
}
|
||||
|
||||
|
|
@ -1346,8 +1348,8 @@ mod tests {
|
|||
"<test>".to_string(),
|
||||
src,
|
||||
Vec::new(), &sess).unwrap();
|
||||
let (mut gated_cfgs, mut loader) = (vec![], DummyMacroLoader);
|
||||
let ecx = ExtCtxt::new(&sess, vec![], test_ecfg(), &mut gated_cfgs, &mut loader);
|
||||
let mut loader = DummyMacroLoader;
|
||||
let ecx = ExtCtxt::new(&sess, vec![], test_ecfg(), &mut loader);
|
||||
expand_crate(ecx, vec![], crate_ast);
|
||||
}
|
||||
|
||||
|
|
@ -1360,8 +1362,8 @@ mod tests {
|
|||
"<test>".to_string(),
|
||||
src,
|
||||
Vec::new(), &sess).unwrap();
|
||||
let (mut gated_cfgs, mut loader) = (vec![], DummyMacroLoader);
|
||||
let ecx = ExtCtxt::new(&sess, vec![], test_ecfg(), &mut gated_cfgs, &mut loader);
|
||||
let mut loader = DummyMacroLoader;
|
||||
let ecx = ExtCtxt::new(&sess, vec![], test_ecfg(), &mut loader);
|
||||
expand_crate(ecx, vec![], crate_ast);
|
||||
}
|
||||
|
||||
|
|
@ -1369,8 +1371,8 @@ mod tests {
|
|||
let ps = parse::ParseSess::new();
|
||||
let crate_ast = panictry!(string_to_parser(&ps, crate_str).parse_crate_mod());
|
||||
// the cfg argument actually does matter, here...
|
||||
let (mut gated_cfgs, mut loader) = (vec![], DummyMacroLoader);
|
||||
let ecx = ExtCtxt::new(&ps, vec![], test_ecfg(), &mut gated_cfgs, &mut loader);
|
||||
let mut loader = DummyMacroLoader;
|
||||
let ecx = ExtCtxt::new(&ps, vec![], test_ecfg(), &mut loader);
|
||||
expand_crate(ecx, vec![], crate_ast).0
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue