File tree 2 files changed +12
-16
lines changed
compiler/rustc_builtin_macros/src/deriving
2 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -107,20 +107,20 @@ fn cs_clone_shallow(
107
107
substr : & Substructure < ' _ > ,
108
108
is_union : bool ,
109
109
) -> P < Expr > {
110
- fn process_variant ( cx : & mut ExtCtxt < ' _ > , stmts : & mut Vec < ast:: Stmt > , variant : & VariantData ) {
110
+ let mut stmts = Vec :: new ( ) ;
111
+ let mut process_variant = |variant : & VariantData | {
111
112
for field in variant. fields ( ) {
112
113
// let _: AssertParamIsClone<FieldTy>;
113
114
super :: assert_ty_bounds (
114
115
cx,
115
- stmts,
116
+ & mut stmts,
116
117
field. ty . clone ( ) ,
117
118
field. span ,
118
119
& [ sym:: clone, sym:: AssertParamIsClone ] ,
119
120
) ;
120
121
}
121
- }
122
+ } ;
122
123
123
- let mut stmts = Vec :: new ( ) ;
124
124
if is_union {
125
125
// let _: AssertParamIsCopy<Self>;
126
126
let self_ty = cx. ty_path ( cx. path_ident ( trait_span, Ident :: with_dummy_span ( kw:: SelfUpper ) ) ) ;
@@ -134,11 +134,11 @@ fn cs_clone_shallow(
134
134
} else {
135
135
match * substr. fields {
136
136
StaticStruct ( vdata, ..) => {
137
- process_variant ( cx , & mut stmts , vdata) ;
137
+ process_variant ( vdata) ;
138
138
}
139
139
StaticEnum ( enum_def, ..) => {
140
140
for variant in & enum_def. variants {
141
- process_variant ( cx , & mut stmts , & variant. data ) ;
141
+ process_variant ( & variant. data ) ;
142
142
}
143
143
}
144
144
_ => cx. span_bug (
Original file line number Diff line number Diff line change @@ -55,31 +55,27 @@ fn cs_total_eq_assert(
55
55
trait_span : Span ,
56
56
substr : & Substructure < ' _ > ,
57
57
) -> P < Expr > {
58
- fn process_variant (
59
- cx : & mut ExtCtxt < ' _ > ,
60
- stmts : & mut Vec < ast:: Stmt > ,
61
- variant : & ast:: VariantData ,
62
- ) {
58
+ let mut stmts = Vec :: new ( ) ;
59
+ let mut process_variant = |variant : & ast:: VariantData | {
63
60
for field in variant. fields ( ) {
64
61
// let _: AssertParamIsEq<FieldTy>;
65
62
super :: assert_ty_bounds (
66
63
cx,
67
- stmts,
64
+ & mut stmts,
68
65
field. ty . clone ( ) ,
69
66
field. span ,
70
67
& [ sym:: cmp, sym:: AssertParamIsEq ] ,
71
68
) ;
72
69
}
73
- }
70
+ } ;
74
71
75
- let mut stmts = Vec :: new ( ) ;
76
72
match * substr. fields {
77
73
StaticStruct ( vdata, ..) => {
78
- process_variant ( cx , & mut stmts , vdata) ;
74
+ process_variant ( vdata) ;
79
75
}
80
76
StaticEnum ( enum_def, ..) => {
81
77
for variant in & enum_def. variants {
82
- process_variant ( cx , & mut stmts , & variant. data ) ;
78
+ process_variant ( & variant. data ) ;
83
79
}
84
80
}
85
81
_ => cx. span_bug ( trait_span, "unexpected substructure in `derive(Eq)`" ) ,
You can’t perform that action at this time.
0 commit comments