diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-09-30 11:01:23 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-10-01 09:26:15 -0700 |
| commit | eafbcfb73cad912a0b2c2ec24f028257e5f2f999 (patch) | |
| tree | e1f95cc9c7cd6b3a75700ca7884ebd811d4309da /src/libsyntax/ext | |
| parent | 12404aaaddd1edc0c59e21f03a9f5ac8df828dcf (diff) | |
| download | rust-eafbcfb73cad912a0b2c2ec24f028257e5f2f999.tar.gz rust-eafbcfb73cad912a0b2c2ec24f028257e5f2f999.zip | |
Change the format! statics to be all-caps
This lets them get past the non_uppercase_statics lint mode (if it's turned on) Closes #9631
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/format.rs | 28 |
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))); |
