about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-10-01 11:26:27 -0700
committerbors <bors@rust-lang.org>2013-10-01 11:26:27 -0700
commitc8cdabc32fc7c6a5c3b01ef24340bc2f4b1ae359 (patch)
tree333abfadefa05bf675f8368212f5a3d0558ae7bc /src/libsyntax
parent24a253778aa26222cae97e3b57f85e5054a39977 (diff)
parenteafbcfb73cad912a0b2c2ec24f028257e5f2f999 (diff)
downloadrust-c8cdabc32fc7c6a5c3b01ef24340bc2f4b1ae359.tar.gz
rust-c8cdabc32fc7c6a5c3b01ef24340bc2f4b1ae359.zip
auto merge of #9633 : alexcrichton/rust/issue-9631, r=huonw
Closes #9631
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/format.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs
index a9e5318db40..11d9713af98 100644
--- a/src/libsyntax/ext/format.rs
+++ b/src/libsyntax/ext/format.rs
@@ -319,6 +319,17 @@ impl Context {
         }
     }
 
+    /// These attributes are applied to all statics that this syntax extension
+    /// will generate.
+    fn static_attrs(&self) -> ~[ast::Attribute] {
+        // Flag statics as `address_insignificant` so LLVM can merge duplicate
+        // globals as much as possible (which we're generating a whole lot of).
+        let unnamed = self.ecx.meta_word(self.fmtsp, @"address_insignificant");
+        let unnamed = self.ecx.attribute(self.fmtsp, unnamed);
+
+        return ~[unnamed];
+    }
+
     /// Translate a `parse::Piece` to a static `rt::Piece`
     fn trans_piece(&mut self, piece: &parse::Piece) -> @ast::Expr {
         let sp = self.fmtsp;
@@ -444,14 +455,9 @@ impl Context {
                 ~[]
             ), None);
             let st = ast::item_static(ty, ast::MutImmutable, method);
-            let static_name = self.ecx.ident_of(format!("__static_method_{}",
+            let static_name = self.ecx.ident_of(format!("__STATIC_METHOD_{}",
                                                      self.method_statics.len()));
-            // Flag these statics as `address_insignificant` so LLVM can
-            // merge duplicate globals as much as possible (which we're
-            // generating a whole lot of).
-            let unnamed = self.ecx.meta_word(self.fmtsp, @"address_insignificant");
-            let unnamed = self.ecx.attribute(self.fmtsp, unnamed);
-            let item = self.ecx.item(sp, static_name, ~[unnamed], st);
+            let item = self.ecx.item(sp, static_name, self.static_attrs(), st);
             self.method_statics.push(item);
             self.ecx.expr_ident(sp, static_name)
         };
@@ -572,11 +578,9 @@ impl Context {
         );
         let ty = self.ecx.ty(self.fmtsp, ty);
         let st = ast::item_static(ty, ast::MutImmutable, fmt);
-        let static_name = self.ecx.ident_of("__static_fmtstr");
-        // see above comment for `address_insignificant` and why we do it
-        let unnamed = self.ecx.meta_word(self.fmtsp, @"address_insignificant");
-        let unnamed = self.ecx.attribute(self.fmtsp, unnamed);
-        let item = self.ecx.item(self.fmtsp, static_name, ~[unnamed], st);
+        let static_name = self.ecx.ident_of("__STATIC_FMTSTR");
+        let item = self.ecx.item(self.fmtsp, static_name,
+                                 self.static_attrs(), st);
         let decl = respan(self.fmtsp, ast::DeclItem(item));
         lets.push(@respan(self.fmtsp, ast::StmtDecl(@decl, ast::DUMMY_NODE_ID)));