@@ -40,7 +40,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
40
40
ret_ty: Self ,
41
41
attributes: attrs,
42
42
combine_substructure: combine_substructure( |c, s, sub| {
43
- cs_clone( "Clone" , c, s, sub)
43
+ cs_clone( c, s, sub)
44
44
} ) ,
45
45
}
46
46
)
@@ -50,14 +50,15 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
50
50
}
51
51
52
52
fn cs_clone (
53
- name : & str ,
54
- cx : & mut ExtCtxt , trait_span : Span ,
53
+ cx : & mut ExtCtxt ,
54
+ trait_span : Span ,
55
55
substr : & Substructure ) -> Gc < Expr > {
56
56
let clone_ident = substr. method_ident ;
57
57
let ctor_ident;
58
58
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
+ } ;
61
62
62
63
match * substr. fields {
63
64
Struct ( ref af) => {
@@ -68,16 +69,11 @@ fn cs_clone(
68
69
ctor_ident = variant. node . name ;
69
70
all_fields = af;
70
71
} ,
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)]`" )
76
74
}
77
75
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)]`" )
81
77
}
82
78
}
83
79
@@ -91,10 +87,8 @@ fn cs_clone(
91
87
let ident = match field. name {
92
88
Some ( i) => i,
93
89
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)]`")
98
92
}
99
93
} ;
100
94
cx. field_imm ( field. span , ident, subcall ( field) )
0 commit comments