Skip to content

Commit 1a90f24

Browse files
committed
extra: minor cleanup of Zero and Default syntax extension
1 parent 5ab843f commit 1a90f24

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/libsyntax/ext/deriving/default.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ fn default_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Exp
4747
cx.ident_of("Default"),
4848
cx.ident_of("default")
4949
];
50-
let default_call = || {
51-
cx.expr_call_global(span, default_ident.clone(), ~[])
52-
};
50+
let default_call = cx.expr_call_global(span, default_ident.clone(), ~[]);
5351

5452
return match *substr.fields {
5553
StaticStruct(_, ref summary) => {
@@ -58,13 +56,13 @@ fn default_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Exp
5856
if count == 0 {
5957
cx.expr_ident(span, substr.type_ident)
6058
} else {
61-
let exprs = vec::from_fn(count, |_| default_call());
59+
let exprs = vec::from_elem(count, default_call);
6260
cx.expr_call_ident(span, substr.type_ident, exprs)
6361
}
6462
}
6563
Right(ref fields) => {
6664
let default_fields = do fields.map |ident| {
67-
cx.field_imm(span, *ident, default_call())
65+
cx.field_imm(span, *ident, default_call)
6866
};
6967
cx.expr_struct_ident(span, substr.type_ident, default_fields)
7068
}

src/libsyntax/ext/deriving/zero.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ fn zero_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
6262
cx.ident_of("Zero"),
6363
cx.ident_of("zero")
6464
];
65-
let zero_call = || {
66-
cx.expr_call_global(span, zero_ident.clone(), ~[])
67-
};
65+
let zero_call = cx.expr_call_global(span, zero_ident.clone(), ~[]);
6866

6967
return match *substr.fields {
7068
StaticStruct(_, ref summary) => {
@@ -73,13 +71,13 @@ fn zero_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
7371
if count == 0 {
7472
cx.expr_ident(span, substr.type_ident)
7573
} else {
76-
let exprs = vec::from_fn(count, |_| zero_call());
74+
let exprs = vec::from_elem(count, zero_call);
7775
cx.expr_call_ident(span, substr.type_ident, exprs)
7876
}
7977
}
8078
Right(ref fields) => {
8179
let zero_fields = do fields.map |ident| {
82-
cx.field_imm(span, *ident, zero_call())
80+
cx.field_imm(span, *ident, zero_call)
8381
};
8482
cx.expr_struct_ident(span, substr.type_ident, zero_fields)
8583
}

0 commit comments

Comments
 (0)