Skip to content

Commit 0e005ab

Browse files
committed
to_str -- update to contain scope of closure
1 parent 0f5baad commit 0e005ab

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

src/libsyntax/ext/deriving/to_str.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,32 @@ fn to_str_substructure(cx: &mut ExtCtxt, span: Span, substr: &Substructure)
6767
let mut stmts = ~[cx.stmt_let(span, true, buf, init)];
6868
let push_str = cx.ident_of("push_str");
6969

70-
let push = |s: @Expr| {
71-
let ebuf = cx.expr_ident(span, buf);
72-
let call = cx.expr_method_call(span, ebuf, push_str, ~[s]);
73-
stmts.push(cx.stmt_expr(call));
74-
};
70+
{
71+
let push = |s: @Expr| {
72+
let ebuf = cx.expr_ident(span, buf);
73+
let call = cx.expr_method_call(span, ebuf, push_str, ~[s]);
74+
stmts.push(cx.stmt_expr(call));
75+
};
7576

76-
for (i, &FieldInfo {name, span, self_, .. }) in fields.iter().enumerate() {
77-
if i > 0 {
78-
push(cx.expr_str(span, InternedString::new(", ")));
79-
}
80-
match name {
81-
None => {}
82-
Some(id) => {
83-
let interned_id = token::get_ident(id.name);
84-
let name = interned_id.get() + ": ";
85-
push(cx.expr_str(span,
86-
token::intern_and_get_ident(name)));
77+
for (i, &FieldInfo {name, span, self_, .. }) in fields.iter().enumerate() {
78+
if i > 0 {
79+
push(cx.expr_str(span, InternedString::new(", ")));
80+
}
81+
match name {
82+
None => {}
83+
Some(id) => {
84+
let interned_id = token::get_ident(id.name);
85+
let name = interned_id.get() + ": ";
86+
push(cx.expr_str(span,
87+
token::intern_and_get_ident(name)));
88+
}
8789
}
90+
push(cx.expr_method_call(span, self_, to_str, ~[]));
8891
}
89-
push(cx.expr_method_call(span, self_, to_str, ~[]));
92+
push(cx.expr_str(span, end));
9093
}
91-
push(cx.expr_str(span, end));
9294

93-
cx.expr_block(cx.block(span, stmts, Some(cx.expr_ident(span,
94-
buf))))
95+
cx.expr_block(cx.block(span, stmts, Some(cx.expr_ident(span, buf))))
9596
}
9697
};
9798

0 commit comments

Comments
 (0)