Rebasing and making MulitDecorators work
This commit is contained in:
parent
0a62a05c67
commit
0a4f9a2696
4 changed files with 13 additions and 36 deletions
|
|
@ -14,13 +14,8 @@ use lint::{LintPassObject, LintId, Lint};
|
|||
use session::Session;
|
||||
|
||||
use syntax::ext::base::{SyntaxExtension, NamedSyntaxExtension, NormalTT};
|
||||
<<<<<<< HEAD
|
||||
use syntax::ext::base::{IdentTT, Decorator, Modifier, MultiModifier, MacroRulesTT};
|
||||
use syntax::ext::base::MacroExpanderFn;
|
||||
=======
|
||||
use syntax::ext::base::{IdentTT, Decorator, MultiDecorator, Modifier, MultiModifier, MacroRulesTT};
|
||||
use syntax::ext::base::{MacroExpanderFn};
|
||||
>>>>>>> 143f2db3174103e459218958f567985b1f47944b
|
||||
use syntax::ext::base::{IdentTT, Decorator, Modifier, MultiModifier, MultiDecorator};
|
||||
use syntax::ext::base::{MacroExpanderFn, MacroRulesTT};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
use syntax::ptr::P;
|
||||
|
|
|
|||
|
|
@ -145,18 +145,18 @@ pub trait MultiItemDecorator {
|
|||
sp: Span,
|
||||
meta_item: &ast::MetaItem,
|
||||
item: &Annotatable,
|
||||
push: Box<FnMut(Annotatable)>);
|
||||
push: &mut FnMut(Annotatable));
|
||||
}
|
||||
|
||||
impl<F> MultiItemDecorator for F
|
||||
where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &Annotatable, Box<FnMut(Annotatable)>)
|
||||
where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &Annotatable, &mut FnMut(Annotatable))
|
||||
{
|
||||
fn expand(&self,
|
||||
ecx: &mut ExtCtxt,
|
||||
sp: Span,
|
||||
meta_item: &ast::MetaItem,
|
||||
item: &Annotatable,
|
||||
push: Box<FnMut(Annotatable)>) {
|
||||
push: &mut FnMut(Annotatable)) {
|
||||
(*self)(ecx, sp, meta_item, item, push)
|
||||
}
|
||||
}
|
||||
|
|
@ -515,13 +515,6 @@ fn initial_syntax_expander_table<'feat>(ecfg: &expand::ExpansionConfig<'feat>)
|
|||
syntax_expanders.insert(intern("log_syntax"),
|
||||
builtin_normal_expander(
|
||||
ext::log_syntax::expand_syntax_ext));
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
syntax_expanders.insert(intern("derive"),
|
||||
MultiDecorator(box ext::deriving::expand_meta_derive));
|
||||
syntax_expanders.insert(intern("deriving"),
|
||||
MultiDecorator(box ext::deriving::expand_deprecated_deriving));
|
||||
>>>>>>> 143f2db3174103e459218958f567985b1f47944b
|
||||
|
||||
ext::deriving::register_all(&mut syntax_expanders);
|
||||
|
||||
|
|
@ -586,11 +579,6 @@ fn initial_syntax_expander_table<'feat>(ecfg: &expand::ExpansionConfig<'feat>)
|
|||
syntax_expanders.insert(intern("cfg"),
|
||||
builtin_normal_expander(
|
||||
ext::cfg::expand_cfg));
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
syntax_expanders.insert(intern("cfg_attr"),
|
||||
MultiModifier(box ext::cfg_attr::expand));
|
||||
>>>>>>> 143f2db3174103e459218958f567985b1f47944b
|
||||
syntax_expanders.insert(intern("trace_macros"),
|
||||
builtin_normal_expander(
|
||||
ext::trace_macros::expand_trace_macros));
|
||||
|
|
|
|||
|
|
@ -80,17 +80,8 @@ pub mod generic;
|
|||
fn expand_derive(cx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
mitem: &MetaItem,
|
||||
annotatable: &Annotatable)
|
||||
-> P<Annotatable> {
|
||||
// Derive can only be applied to items
|
||||
let item = match annotatable {
|
||||
&Annotatable::Item(ref it) => it.clone(),
|
||||
_ => {
|
||||
cx.span_err(span, "`derive` can only be applied to items");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
item: P<Item>)
|
||||
-> P<Item> {
|
||||
item.map(|mut item| {
|
||||
if mitem.value_str().is_some() {
|
||||
cx.span_err(mitem.span, "unexpected value in `derive`");
|
||||
|
|
@ -123,7 +114,7 @@ fn expand_derive(cx: &mut ExtCtxt,
|
|||
intern_and_get_ident(&format!("derive_{}", tname)))));
|
||||
}
|
||||
|
||||
Annotatable::Item(item)
|
||||
item
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1134,9 +1134,12 @@ fn expand_annotatable(a: Annotatable,
|
|||
fld.cx.bt_push(ExpnInfo {
|
||||
call_site: attr.span,
|
||||
callee: NameAndSpan {
|
||||
name: mname.get().to_string(),
|
||||
name: mname.to_string(),
|
||||
format: MacroAttribute,
|
||||
span: None
|
||||
span: Some(attr.span),
|
||||
// attributes can do whatever they like,
|
||||
// for now.
|
||||
allow_internal_unstable: true,
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue