]> git.lizzy.rs Git - rust.git/commitdiff
Rebasing and making MulitDecorators work
authorNick Cameron <ncameron@mozilla.com>
Sat, 25 Apr 2015 03:31:11 +0000 (15:31 +1200)
committerNick Cameron <ncameron@mozilla.com>
Sat, 25 Apr 2015 03:31:11 +0000 (15:31 +1200)
src/librustc/plugin/registry.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/deriving/mod.rs
src/libsyntax/ext/expand.rs

index fccde9a2f178898c0dc97d555b9cca29f9c09d4f..04df464129541aeee9fd75253d187d3f36f931e9 100644 (file)
 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;
index f84d3ed98c7676cc150a33fbc169d6ede4d194e0..3e54e43c0296144641bb42dc2111d6d70a4897bd 100644 (file)
@@ -145,18 +145,18 @@ fn expand(&self,
               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 builtin_normal_expander(f: MacroExpanderFn) -> SyntaxExtension {
     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 builtin_normal_expander(f: MacroExpanderFn) -> SyntaxExtension {
     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));
index 586e73ad64554d7c240698183b2dea1a3598cc62..bc4a7f90911dc37fc130b5f7c4bfbe7808ae59ca 100644 (file)
@@ -80,17 +80,8 @@ macro_rules! path_std {
 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
     })
 }
 
index 76a4ef2f4ed721e5c8eca0159716961120036c9f..106d862042a9047e0c39764837127349ef9c2e76 100644 (file)
@@ -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,
                         }
                     });