about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-03-04 19:41:38 -0800
committerbors <bors@rust-lang.org>2014-03-04 19:41:38 -0800
commit3cc761f3f97b0a5ff5e355430bb4e52b15f567b6 (patch)
tree766b626b82f1816b4567c05adb461abf6f93c5ca /src/libsyntax
parentf1955e028cd3ea5097845f183f8cd099014ac6d8 (diff)
parent4a891fe80dfc5c64d72ddb842751bf410dc7a3a8 (diff)
downloadrust-3cc761f3f97b0a5ff5e355430bb4e52b15f567b6.tar.gz
rust-3cc761f3f97b0a5ff5e355430bb4e52b15f567b6.zip
auto merge of #12671 : nick29581/rust/expand, r=sfackler
Fixes a regression from #4913 which causes items to be exanded with spans lacking expn_info from the context's current backtrace.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/expand.rs13
-rw-r--r--src/libsyntax/util/small_vector.rs8
2 files changed, 15 insertions, 6 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index d8b4334c867..13c340cb774 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -248,7 +248,7 @@ macro_rules! with_exts_frame (
 // When we enter a module, record it, for the sake of `module!`
 pub fn expand_item(it: @ast::Item, fld: &mut MacroExpander)
                    -> SmallVector<@ast::Item> {
-    let mut decorator_items = SmallVector::zero();
+    let mut decorator_items: SmallVector<@ast::Item> = SmallVector::zero();
     for attr in it.attrs.rev_iter() {
         let mname = attr.name();
 
@@ -262,20 +262,21 @@ pub fn expand_item(it: @ast::Item, fld: &mut MacroExpander)
                         span: None
                     }
                 });
+
                 // we'd ideally decorator_items.push_all(expand_item(item, fld)),
                 // but that double-mut-borrows fld
+                let mut items: SmallVector<@ast::Item> = SmallVector::zero();
                 dec_fn(fld.cx, attr.span, attr.node.value, it,
-                       |item| decorator_items.push(item));
+                       |item| items.push(item));
+                decorator_items.extend(&mut items.move_iter()
+                    .flat_map(|item| expand_item(item, fld).move_iter()));
+
                 fld.cx.bt_pop();
             }
             _ => {}
         }
     }
 
-    let decorator_items = decorator_items.move_iter()
-        .flat_map(|item| expand_item(item, fld).move_iter())
-        .collect();
-
     let mut new_items = match it.node {
         ast::ItemMac(..) => expand_item_mac(it, fld),
         ast::ItemMod(_) | ast::ItemForeignMod(_) => {
diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs
index 9eb9871bb21..f15b7dd5563 100644
--- a/src/libsyntax/util/small_vector.rs
+++ b/src/libsyntax/util/small_vector.rs
@@ -39,6 +39,14 @@ impl<T> FromIterator<T> for SmallVector<T> {
     }
 }
 
+impl<T> Extendable<T> for SmallVector<T> {
+    fn extend<I: Iterator<T>>(&mut self, iter: &mut I) {
+        for val in *iter {
+            self.push(val);
+        }
+    }
+}
+
 impl<T> SmallVector<T> {
     pub fn zero() -> SmallVector<T> {
         Zero