Skip to content

Commit 2d38f5d

Browse files
committed
syntax: minor cleanup of #[deriving(Clone)]
1 parent e9bf0ac commit 2d38f5d

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

src/libsyntax/ext/deriving/clone.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
4040
ret_ty: Self,
4141
attributes: attrs,
4242
combine_substructure: combine_substructure(|c, s, sub| {
43-
cs_clone("Clone", c, s, sub)
43+
cs_clone(c, s, sub)
4444
}),
4545
}
4646
)
@@ -50,14 +50,15 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
5050
}
5151

5252
fn cs_clone(
53-
name: &str,
54-
cx: &mut ExtCtxt, trait_span: Span,
53+
cx: &mut ExtCtxt,
54+
trait_span: Span,
5555
substr: &Substructure) -> Gc<Expr> {
5656
let clone_ident = substr.method_ident;
5757
let ctor_ident;
5858
let all_fields;
59-
let subcall = |field: &FieldInfo|
60-
cx.expr_method_call(field.span, field.self_, clone_ident, Vec::new());
59+
let subcall = |field: &FieldInfo| {
60+
cx.expr_method_call(field.span, field.self_, clone_ident, Vec::new())
61+
};
6162

6263
match *substr.fields {
6364
Struct(ref af) => {
@@ -68,16 +69,11 @@ fn cs_clone(
6869
ctor_ident = variant.node.name;
6970
all_fields = af;
7071
},
71-
EnumNonMatchingCollapsed (..) => {
72-
cx.span_bug(trait_span,
73-
format!("non-matching enum variants in \
74-
`deriving({})`",
75-
name).as_slice())
72+
EnumNonMatchingCollapsed(..) => {
73+
cx.span_bug(trait_span, "non-matching enum variants in `#[deriving(Clone)]`")
7674
}
7775
StaticEnum(..) | StaticStruct(..) => {
78-
cx.span_bug(trait_span,
79-
format!("static method in `deriving({})`",
80-
name).as_slice())
76+
cx.span_bug(trait_span, "static method in `#[deriving(Clone)]`")
8177
}
8278
}
8379

@@ -91,10 +87,8 @@ fn cs_clone(
9187
let ident = match field.name {
9288
Some(i) => i,
9389
None => {
94-
cx.span_bug(trait_span,
95-
format!("unnamed field in normal struct in \
96-
`deriving({})`",
97-
name).as_slice())
90+
cx.span_bug(trait_span, "unnamed field in normal struct in \
91+
`#[deriving(Clone)]`")
9892
}
9993
};
10094
cx.field_imm(field.span, ident, subcall(field))

0 commit comments

Comments
 (0)