about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2015-04-25 15:31:11 +1200
committerNick Cameron <ncameron@mozilla.com>2015-04-25 15:31:11 +1200
commit0a4f9a26962d85d57a0b603ad324bd86fdd474cf (patch)
tree52e799f280dc9482bd00dd36ef4535f1a26d8eee
parent0a62a05c6736dce542529cb1eb67fc54c0b70db4 (diff)
downloadrust-0a4f9a26962d85d57a0b603ad324bd86fdd474cf.tar.gz
rust-0a4f9a26962d85d57a0b603ad324bd86fdd474cf.zip
Rebasing and making MulitDecorators work
-rw-r--r--src/librustc/plugin/registry.rs9
-rw-r--r--src/libsyntax/ext/base.rs18
-rw-r--r--src/libsyntax/ext/deriving/mod.rs15
-rw-r--r--src/libsyntax/ext/expand.rs7
4 files changed, 13 insertions, 36 deletions
diff --git a/src/librustc/plugin/registry.rs b/src/librustc/plugin/registry.rs
index fccde9a2f17..04df4641295 100644
--- a/src/librustc/plugin/registry.rs
+++ b/src/librustc/plugin/registry.rs
@@ -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;
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index f84d3ed98c7..3e54e43c029 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -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));
diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs
index 586e73ad645..bc4a7f90911 100644
--- a/src/libsyntax/ext/deriving/mod.rs
+++ b/src/libsyntax/ext/deriving/mod.rs
@@ -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
     })
 }
 
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 76a4ef2f4ed..106d862042a 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -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,
                         }
                     });