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

0 commit comments

Comments
 (0)