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;
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)
}
}
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);
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));
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`");
intern_and_get_ident(&format!("derive_{}", tname)))));
}
- Annotatable::Item(item)
+ item
})
}
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,
}
});