Skip to content

Commit fe05837

Browse files
committed
Merge pull request #3746 from killerswan/nuke_fmt
Replace several common macros of the form #m[...] with m!(...)
2 parents 45d1cd8 + 1bede1f commit fe05837

40 files changed

+85
-86
lines changed

src/libstd/net_url.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ fn encode_inner(s: &str, full_url: bool) -> ~str {
6565
str::push_char(&mut out, ch);
6666
}
6767

68-
_ => out += #fmt("%%%X", ch as uint)
68+
_ => out += fmt!("%%%X", ch as uint)
6969
}
7070
} else {
71-
out += #fmt("%%%X", ch as uint);
71+
out += fmt!("%%%X", ch as uint);
7272
}
7373
}
7474
}
@@ -164,7 +164,7 @@ fn encode_plus(s: &str) -> ~str {
164164
str::push_char(&mut out, ch);
165165
}
166166
' ' => str::push_char(&mut out, '+'),
167-
_ => out += #fmt("%%%X", ch as uint)
167+
_ => out += fmt!("%%%X", ch as uint)
168168
}
169169
}
170170

@@ -190,7 +190,7 @@ pub fn encode_form_urlencoded(m: HashMap<~str, @DVec<@~str>>) -> ~str {
190190
first = false;
191191
}
192192

193-
out += #fmt("%s=%s", key, encode_plus(**value));
193+
out += fmt!("%s=%s", key, encode_plus(**value));
194194
}
195195
}
196196

@@ -332,7 +332,7 @@ pub pure fn query_to_str(query: Query) -> ~str {
332332
let (k, v) = copy *kv;
333333
// This is really safe...
334334
unsafe {
335-
strvec += ~[#fmt("%s=%s",
335+
strvec += ~[fmt!("%s=%s",
336336
encode_component(k), encode_component(v))];
337337
}
338338
};
@@ -850,7 +850,7 @@ mod tests {
850850
fn test_url_parse_host_slash() {
851851
let urlstr = ~"http://0.42.42.42/";
852852
let url = from_str(urlstr).get();
853-
#debug("url: %?", url);
853+
debug!("url: %?", url);
854854
assert url.host == ~"0.42.42.42";
855855
assert url.path == ~"/";
856856
}
@@ -859,15 +859,15 @@ mod tests {
859859
fn test_url_with_underscores() {
860860
let urlstr = ~"http://dotcom.com/file_name.html";
861861
let url = from_str(urlstr).get();
862-
#debug("url: %?", url);
862+
debug!("url: %?", url);
863863
assert url.path == ~"/file_name.html";
864864
}
865865

866866
#[test]
867867
fn test_url_with_dashes() {
868868
let urlstr = ~"http://dotcom.com/file-name.html";
869869
let url = from_str(urlstr).get();
870-
#debug("url: %?", url);
870+
debug!("url: %?", url);
871871
assert url.path == ~"/file-name.html";
872872
}
873873

src/libstd/serialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ pub impl<T: Deserializable> Option<T>: Deserializable {
375375
match i {
376376
0 => None,
377377
1 => Some(d.read_enum_variant_arg(0u, || deserialize(d))),
378-
_ => fail(#fmt("Bad variant for option: %u", i))
378+
_ => fail(fmt!("Bad variant for option: %u", i))
379379
}
380380
}
381381
}

src/libstd/time.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,7 @@ pub fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
595595
fn strftime(format: &str, tm: Tm) -> ~str {
596596
fn parse_type(ch: char, tm: &Tm) -> ~str {
597597
//FIXME (#2350): Implement missing types.
598-
let die = || #fmt("strftime: can't understand this format %c ",
599-
ch);
598+
let die = || fmt!("strftime: can't understand this format %c ", ch);
600599
match ch {
601600
'A' => match tm.tm_wday as int {
602601
0 => ~"Sunday",

src/libsyntax/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ fn print_macro_backtrace(cm: codemap::codemap, sp: span) {
266266
let ss = option::map_default(&ei.callie.span, @~"",
267267
|span| @codemap::span_to_str(*span, cm));
268268
print_diagnostic(*ss, note,
269-
fmt!("in expansion of #%s", ei.callie.name));
269+
fmt!("in expansion of %s!", ei.callie.name));
270270
let ss = codemap::span_to_str(ei.call_site, cm);
271271
print_diagnostic(ss, note, ~"expansion site");
272272
print_macro_backtrace(cm, ei.call_site);

src/libsyntax/ext/base.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,21 +269,21 @@ fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
269269
match max {
270270
Some(max) if ! (min <= elts_len && elts_len <= max) => {
271271
cx.span_fatal(sp,
272-
fmt!("#%s takes between %u and %u arguments.",
272+
fmt!("%s! takes between %u and %u arguments.",
273273
name, min, max));
274274
}
275275
None if ! (min <= elts_len) => {
276-
cx.span_fatal(sp, fmt!("#%s needs at least %u arguments.",
276+
cx.span_fatal(sp, fmt!("%s! needs at least %u arguments.",
277277
name, min));
278278
}
279279
_ => return elts /* we are good */
280280
}
281281
}
282282
_ => {
283-
cx.span_fatal(sp, fmt!("#%s: malformed invocation", name))
283+
cx.span_fatal(sp, fmt!("%s!: malformed invocation", name))
284284
}
285285
},
286-
None => cx.span_fatal(sp, fmt!("#%s: missing arguments", name))
286+
None => cx.span_fatal(sp, fmt!("%s!: missing arguments", name))
287287
}
288288
}
289289

src/libsyntax/ext/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/*
3-
* The compiler code necessary to support the #env extension. Eventually this
3+
* The compiler code necessary to support the env! extension. Eventually this
44
* should all get sucked into either the compiler syntax extension plugin
55
* interface.
66
*/
@@ -15,7 +15,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
1515
// FIXME (#2248): if this was more thorough it would manufacture an
1616
// Option<str> rather than just an maybe-empty string.
1717

18-
let var = expr_to_str(cx, args[0], ~"#env requires a string");
18+
let var = expr_to_str(cx, args[0], ~"env! requires a string");
1919
match os::getenv(var) {
2020
option::None => return mk_uniq_str(cx, sp, ~""),
2121
option::Some(s) => return mk_uniq_str(cx, sp, s)

src/libsyntax/ext/fmt.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
/*
4-
* The compiler code necessary to support the #fmt extension. Eventually this
4+
* The compiler code necessary to support the fmt! extension. Eventually this
55
* should all get sucked into either the standard library extfmt module or the
66
* compiler syntax extension plugin interface.
77
*/
@@ -16,7 +16,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
1616
let args = get_mac_args_no_max(cx, sp, arg, 1u, ~"fmt");
1717
let fmt =
1818
expr_to_str(cx, args[0],
19-
~"first argument to #fmt must be a string literal.");
19+
~"first argument to fmt! must be a string literal.");
2020
let fmtspan = args[0].span;
2121
debug!("Format string:");
2222
log(debug, fmt);
@@ -76,7 +76,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
7676
let count_is_args = ~[count_lit];
7777
return mk_call(cx, sp, count_is_path, count_is_args);
7878
}
79-
_ => cx.span_unimpl(sp, ~"unimplemented #fmt conversion")
79+
_ => cx.span_unimpl(sp, ~"unimplemented fmt! conversion")
8080
}
8181
}
8282
fn make_ty(cx: ext_ctxt, sp: span, t: Ty) -> @ast::expr {
@@ -133,7 +133,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
133133
_ => return false
134134
}
135135
}
136-
let unsupported = ~"conversion not supported in #fmt string";
136+
let unsupported = ~"conversion not supported in fmt! string";
137137
match cnv.param {
138138
option::None => (),
139139
_ => cx.span_unimpl(sp, unsupported)
@@ -145,14 +145,14 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
145145
if !is_signed_type(cnv) {
146146
cx.span_fatal(sp,
147147
~"+ flag only valid in " +
148-
~"signed #fmt conversion");
148+
~"signed fmt! conversion");
149149
}
150150
}
151151
FlagSpaceForSign => {
152152
if !is_signed_type(cnv) {
153153
cx.span_fatal(sp,
154154
~"space flag only valid in " +
155-
~"signed #fmt conversions");
155+
~"signed fmt! conversions");
156156
}
157157
}
158158
FlagLeftZeroPad => (),
@@ -252,7 +252,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
252252
n += 1u;
253253
if n >= nargs {
254254
cx.span_fatal(sp,
255-
~"not enough arguments to #fmt " +
255+
~"not enough arguments to fmt! " +
256256
~"for the given format string");
257257
}
258258
debug!("Building conversion:");
@@ -267,7 +267,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
267267

268268
if expected_nargs < nargs {
269269
cx.span_fatal
270-
(sp, fmt!("too many arguments to #fmt. found %u, expected %u",
270+
(sp, fmt!("too many arguments to fmt!. found %u, expected %u",
271271
nargs, expected_nargs));
272272
}
273273

src/libsyntax/parse/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,7 +2414,7 @@ impl parser {
24142414

24152415
fn expect_self_ident() {
24162416
if !self.is_self_ident() {
2417-
self.fatal(#fmt("expected `self` but found `%s`",
2417+
self.fatal(fmt!("expected `self` but found `%s`",
24182418
token_to_str(self.reader, self.token)));
24192419
}
24202420
self.bump();
@@ -2696,7 +2696,7 @@ impl parser {
26962696
ctor_decl(a_fn_decl, attrs, blk, s) => {
26972697
match the_ctor {
26982698
Some((_, _, _, s_first)) => {
2699-
self.span_note(s, #fmt("Duplicate constructor \
2699+
self.span_note(s, fmt!("Duplicate constructor \
27002700
declaration for class %s",
27012701
*self.interner.get(class_name)));
27022702
self.span_fatal(copy s_first, ~"First constructor \
@@ -2710,7 +2710,7 @@ impl parser {
27102710
dtor_decl(blk, attrs, s) => {
27112711
match the_dtor {
27122712
Some((_, _, s_first)) => {
2713-
self.span_note(s, #fmt("Duplicate destructor \
2713+
self.span_note(s, fmt!("Duplicate destructor \
27142714
declaration for class %s",
27152715
*self.interner.get(class_name)));
27162716
self.span_fatal(copy s_first, ~"First destructor \

src/rustc/driver/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl session {
216216
// This exists to help with refactoring to eliminate impossible
217217
// cases later on
218218
fn impossible_case(sp: span, msg: &str) -> ! {
219-
self.span_bug(sp, #fmt("Impossible case reached: %s", msg));
219+
self.span_bug(sp, fmt!("Impossible case reached: %s", msg));
220220
}
221221
fn verbose() -> bool { self.debugging_opt(verbose) }
222222
fn time_passes() -> bool { self.debugging_opt(time_passes) }

src/rustc/metadata/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn item_family(item: ebml::Doc) -> Family {
162162
'g' => PublicField,
163163
'j' => PrivateField,
164164
'N' => InheritedField,
165-
c => fail (#fmt("unexpected family char: %c", c))
165+
c => fail (fmt!("unexpected family char: %c", c))
166166
}
167167
}
168168

@@ -705,7 +705,7 @@ fn get_trait_methods(intr: @ident_interner, cdata: cmd, id: ast::node_id,
705705
self_ty: self_ty,
706706
vis: ast::public});
707707
}
708-
#debug("get_trait_methods: }");
708+
debug!("get_trait_methods: }");
709709
@result
710710
}
711711

src/rustc/middle/borrowck/gather_loans.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ impl gather_loan_ctxt {
303303
_ => {
304304
self.bccx.tcx.sess.span_bug(
305305
cmt.span,
306-
#fmt["loans required but scope is scope_region is %s",
307-
region_to_str(self.tcx(), scope_r)]);
306+
fmt!("loans required but scope is scope_region is %s",
307+
region_to_str(self.tcx(), scope_r)));
308308
}
309309
}
310310
}

src/rustc/middle/borrowck/preserve.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,17 +314,17 @@ priv impl &preserve_ctxt {
314314
// we can only root values if the desired region is some concrete
315315
// scope within the fn body
316316
ty::re_scope(scope_id) => {
317-
#debug["Considering root map entry for %s: \
317+
debug!("Considering root map entry for %s: \
318318
node %d:%u -> scope_id %?, root_ub %?",
319319
self.bccx.cmt_to_repr(cmt), base.id,
320-
derefs, scope_id, self.root_ub];
320+
derefs, scope_id, self.root_ub);
321321
if self.bccx.is_subregion_of(self.scope_region, root_region) {
322-
#debug["Elected to root"];
322+
debug!("Elected to root");
323323
let rk = {id: base.id, derefs: derefs};
324324
self.bccx.root_map.insert(rk, scope_id);
325325
return Ok(pc_ok);
326326
} else {
327-
#debug["Unable to root"];
327+
debug!("Unable to root");
328328
return Err({cmt:cmt,
329329
code:err_out_of_root_scope(root_region,
330330
self.scope_region)});

src/rustc/middle/check_alt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) {
3333
if arms.is_empty() {
3434
if !type_is_empty(tcx, pat_ty) {
3535
// We know the type is inhabited, so this must be wrong
36-
tcx.sess.span_err(ex.span, #fmt("non-exhaustive patterns: \
36+
tcx.sess.span_err(ex.span, fmt!("non-exhaustive patterns: \
3737
type %s is non-empty", ty_to_str(tcx, pat_ty)));
3838
}
3939
// If the type *is* empty, it's vacuously exhaustive

src/rustc/middle/liveness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,11 +902,11 @@ impl Liveness {
902902
self.propagate_through_fn_block(decl, body)
903903
});
904904

905-
// hack to skip the loop unless #debug is enabled:
905+
// hack to skip the loop unless debug! is enabled:
906906
debug!("^^ liveness computation results for body %d (entry=%s)",
907907
{
908908
for uint::range(0u, self.ir.num_live_nodes) |ln_idx| {
909-
#debug["%s", self.ln_str(LiveNode(ln_idx))];
909+
debug!("%s", self.ln_str(LiveNode(ln_idx)));
910910
}
911911
body.node.id
912912
},

src/rustc/middle/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,12 +918,12 @@ impl Resolver {
918918
match ns.find(|n| child.defined_in_namespace(n)) {
919919
Some(ns) => {
920920
self.session.span_err(sp,
921-
#fmt("Duplicate definition of %s %s",
921+
fmt!("Duplicate definition of %s %s",
922922
namespace_to_str(ns),
923923
self.session.str_of(name)));
924924
do child.span_for_namespace(ns).iter() |sp| {
925925
self.session.span_note(*sp,
926-
#fmt("First definition of %s %s here:",
926+
fmt!("First definition of %s %s here:",
927927
namespace_to_str(ns),
928928
self.session.str_of(name)));
929929
}

src/rustc/middle/trans/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ fn emit_tydescs(ccx: @crate_ctxt) {
745745
// Index tydesc by addrspace.
746746
if ti.addrspace > gc_box_addrspace {
747747
let llty = T_ptr(ccx.tydesc_type);
748-
let addrspace_name = #fmt("_gc_addrspace_metadata_%u",
748+
let addrspace_name = fmt!("_gc_addrspace_metadata_%u",
749749
ti.addrspace as uint);
750750
let addrspace_gvar = str::as_c_str(addrspace_name, |buf| {
751751
llvm::LLVMAddGlobal(ccx.llmod, llty, buf)

src/rustc/middle/trans/monomorphize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ fn monomorphic_fn(ccx: @crate_ctxt,
3737
must_cast = true;
3838
}
3939

40-
#debug["monomorphic_fn(fn_id=%? (%s), real_substs=%?, substs=%?, \
40+
debug!("monomorphic_fn(fn_id=%? (%s), real_substs=%?, substs=%?, \
4141
hash_id = %?",
4242
fn_id, ty::item_path_str(ccx.tcx, fn_id),
4343
real_substs.map(|s| ty_to_str(ccx.tcx, *s)),
44-
substs.map(|s| ty_to_str(ccx.tcx, *s)), hash_id];
44+
substs.map(|s| ty_to_str(ccx.tcx, *s)), hash_id);
4545

4646
match ccx.monomorphized.find(hash_id) {
4747
Some(val) => {

src/rustc/middle/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,7 +3020,7 @@ fn get_field(tcx: ctxt, rec_ty: t, id: ast::ident) -> field {
30203020
match vec::find(get_fields(rec_ty), |f| f.ident == id) {
30213021
Some(f) => f,
30223022
// Do we only call this when we know the field is legit?
3023-
None => fail (#fmt("get_field: ty doesn't have a field %s",
3023+
None => fail (fmt!("get_field: ty doesn't have a field %s",
30243024
tcx.sess.str_of(id)))
30253025
}
30263026
}
@@ -3335,7 +3335,7 @@ fn provided_trait_methods(cx: ctxt, id: ast::def_id) -> ~[@ast::method] {
33353335
match ast_util::split_trait_methods(ms) {
33363336
(_, p) => p
33373337
},
3338-
_ => cx.sess.bug(#fmt("provided_trait_methods: %? is not a trait",
3338+
_ => cx.sess.bug(fmt!("provided_trait_methods: %? is not a trait",
33393339
id))
33403340
}
33413341
}

src/rustc/middle/typeck/collect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
266266
}
267267

268268
if impl_m.tps.len() != trait_m.tps.len() {
269-
tcx.sess.span_err(sp, #fmt("method `%s` \
269+
tcx.sess.span_err(sp, fmt!("method `%s` \
270270
has %u type %s, but its trait declaration has %u type %s",
271271
tcx.sess.str_of(trait_m.ident), impl_m.tps.len(),
272272
pluralize(impl_m.tps.len(), ~"parameter"),
@@ -291,7 +291,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
291291
// Would be nice to use the ty param names in the error message,
292292
// but we don't have easy access to them here
293293
if impl_param_bounds.len() != trait_param_bounds.len() {
294-
tcx.sess.span_err(sp, #fmt("in method `%s`, \
294+
tcx.sess.span_err(sp, fmt!("in method `%s`, \
295295
type parameter %u has %u %s, but the same type \
296296
parameter in its trait declaration has %u %s",
297297
tcx.sess.str_of(trait_m.ident),

0 commit comments

Comments
 (0)