Skip to content

Commit 821979f

Browse files
committed
auto merge of #6219 : dotdash/rust/fmt, r=graydon
Only the first portion has to be owned, as it acts as the buffer for the constructed string. The remaining strings can be static.
2 parents 5bf7e8b + 2e3e0c0 commit 821979f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/libsyntax/ext/fmt.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,13 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
273273
match pc {
274274
/* Raw strings get appended via str::push_str */
275275
PieceString(s) => {
276-
let portion = mk_uniq_str(cx, fmt_sp, s);
277-
278276
/* If this is the first portion, then initialize the local
279277
buffer with it directly. If it's actually the only piece,
280278
then there's no need for it to be mutable */
281279
if i == 0 {
282-
stms.push(mk_local(cx, fmt_sp, npieces > 1, ident, portion));
280+
stms.push(mk_local(cx, fmt_sp, npieces > 1, ident, mk_uniq_str(cx, fmt_sp, s)));
283281
} else {
284-
let args = ~[mk_mut_addr_of(cx, fmt_sp, buf()), portion];
282+
let args = ~[mk_mut_addr_of(cx, fmt_sp, buf()), mk_base_str(cx, fmt_sp, s)];
285283
let call = mk_call_global(cx,
286284
fmt_sp,
287285
~[str_ident, push_ident],

0 commit comments

Comments
 (0)