@@ -429,11 +429,11 @@ fn gen_type_info_where_clauses(
429
429
bound_align_hash. push ( syn:: parse_quote!( :: epserde:: traits:: AlignHash ) ) ;
430
430
let align_hash = gen_type_info_where_clause ( bound_align_hash) ;
431
431
432
- let mut bound_align_of = Punctuated :: new ( ) ;
433
- bound_align_of . push ( syn:: parse_quote!( :: epserde:: traits:: AlignTo ) ) ;
434
- let align_of = gen_type_info_where_clause ( bound_align_of ) ;
432
+ let mut bound_align_to = Punctuated :: new ( ) ;
433
+ bound_align_to . push ( syn:: parse_quote!( :: epserde:: traits:: AlignTo ) ) ;
434
+ let align_to = gen_type_info_where_clause ( bound_align_to ) ;
435
435
436
- ( type_hash, align_hash, align_of )
436
+ ( type_hash, align_hash, align_to )
437
437
}
438
438
439
439
/// Context structure for the [`Epserde`] derive macro.
@@ -591,9 +591,7 @@ fn gen_epserde_struct_impl(ctx: &EpserdeContext, s: &syn::DataStruct) -> proc_ma
591
591
use :: epserde:: deser:: DeserInner ;
592
592
593
593
Ok ( #name{
594
- #(
595
- #field_names: unsafe { <#field_types as DeserInner >:: _deser_full_inner( backend) ? } ,
596
- ) *
594
+ #( #field_names: unsafe { <#field_types as DeserInner >:: _deser_full_inner( backend) ? } , ) *
597
595
} )
598
596
}
599
597
@@ -606,9 +604,7 @@ fn gen_epserde_struct_impl(ctx: &EpserdeContext, s: &syn::DataStruct) -> proc_ma
606
604
use :: epserde:: deser:: DeserInner ;
607
605
608
606
Ok ( #name{
609
- #(
610
- #method_calls,
611
- ) *
607
+ #( #method_calls, ) *
612
608
} )
613
609
}
614
610
}
@@ -1114,19 +1110,18 @@ fn gen_enum_align_hash_body(
1114
1110
}
1115
1111
1116
1112
/// Generates the `AlignTo` implementation body for struct types.
1117
- fn gen_struct_align_of_body ( fields_types : & [ & syn:: Type ] ) -> proc_macro2:: TokenStream {
1113
+ fn gen_struct_align_to_body ( fields_types : & [ & syn:: Type ] ) -> proc_macro2:: TokenStream {
1118
1114
quote ! {
1119
1115
use :: epserde:: traits:: AlignTo ;
1120
- use :: epserde:: ser:: SerType ;
1121
1116
1122
- let mut align_of = :: core:: mem:: align_of:: <Self >( ) ;
1117
+ let mut align_to = :: core:: mem:: align_of:: <Self >( ) ;
1123
1118
1124
1119
#(
1125
- if align_of < <#fields_types as AlignTo >:: align_to( ) {
1126
- align_of = <#fields_types as AlignTo >:: align_to( ) ;
1120
+ if align_to < <#fields_types as AlignTo >:: align_to( ) {
1121
+ align_to = <#fields_types as AlignTo >:: align_to( ) ;
1127
1122
}
1128
1123
) *
1129
- align_of
1124
+ align_to
1130
1125
}
1131
1126
}
1132
1127
@@ -1136,21 +1131,21 @@ fn gen_type_info_traits(
1136
1131
ctx : TypeInfoContext ,
1137
1132
type_hash_where_clause : syn:: WhereClause ,
1138
1133
align_hash_where_clause : syn:: WhereClause ,
1139
- align_of_where_clause : syn:: WhereClause ,
1134
+ align_to_where_clause : syn:: WhereClause ,
1140
1135
type_hash_body : proc_macro2:: TokenStream ,
1141
1136
align_hash_body : proc_macro2:: TokenStream ,
1142
- align_of_body : Option < proc_macro2:: TokenStream > ,
1137
+ align_to_body : Option < proc_macro2:: TokenStream > ,
1143
1138
) -> proc_macro2:: TokenStream {
1144
1139
let name = & ctx. name ;
1145
1140
let generics_for_impl = & ctx. generics_for_impl ;
1146
1141
let generics_for_type = & ctx. generics_for_type ;
1147
1142
1148
- let align_of_impl = if let Some ( align_of_body ) = align_of_body {
1143
+ let align_to_impl = if let Some ( align_to_body ) = align_to_body {
1149
1144
quote ! {
1150
1145
#[ automatically_derived]
1151
- impl #generics_for_impl :: epserde:: traits:: AlignTo for #name #generics_for_type #align_of_where_clause {
1146
+ impl #generics_for_impl :: epserde:: traits:: AlignTo for #name #generics_for_type #align_to_where_clause {
1152
1147
fn align_to( ) -> usize {
1153
- #align_of_body
1148
+ #align_to_body
1154
1149
}
1155
1150
}
1156
1151
}
@@ -1168,7 +1163,6 @@ fn gen_type_info_traits(
1168
1163
1169
1164
#[ automatically_derived]
1170
1165
impl #generics_for_impl :: epserde:: traits:: AlignHash for #name #generics_for_type #align_hash_where_clause {
1171
-
1172
1166
fn align_hash(
1173
1167
hasher: & mut impl :: core:: hash:: Hasher ,
1174
1168
offset_of: & mut usize ,
@@ -1177,7 +1171,7 @@ fn gen_type_info_traits(
1177
1171
}
1178
1172
}
1179
1173
1180
- #align_of_impl
1174
+ #align_to_impl
1181
1175
}
1182
1176
}
1183
1177
@@ -1199,7 +1193,7 @@ fn gen_struct_type_info_impl(
1199
1193
field_types_ts. push ( quote ! { SerType <#field_type> } ) ;
1200
1194
}
1201
1195
1202
- let ( type_hash_where_clause, align_hash_where_clause, align_of_where_clause ) =
1196
+ let ( type_hash_where_clause, align_hash_where_clause, align_to_where_clause ) =
1203
1197
gen_type_info_where_clauses ( ctx. where_clause , ctx. is_zero_copy , & field_types) ;
1204
1198
1205
1199
// Generate field hashes for TypeHash
@@ -1215,8 +1209,8 @@ fn gen_struct_type_info_impl(
1215
1209
// Generate implementation bodies
1216
1210
let type_hash_body = gen_type_hash_body ( & ctx, & field_hashes) ;
1217
1211
let align_hash_body = gen_struct_align_hash_body ( & ctx, & field_types_ts) ;
1218
- let align_of_body = if ctx. is_zero_copy {
1219
- Some ( gen_struct_align_of_body ( & field_types) )
1212
+ let align_to_body = if ctx. is_zero_copy {
1213
+ Some ( gen_struct_align_to_body ( & field_types) )
1220
1214
} else {
1221
1215
None
1222
1216
} ;
@@ -1225,18 +1219,18 @@ fn gen_struct_type_info_impl(
1225
1219
ctx,
1226
1220
type_hash_where_clause,
1227
1221
align_hash_where_clause,
1228
- align_of_where_clause ,
1222
+ align_to_where_clause ,
1229
1223
type_hash_body,
1230
1224
align_hash_body,
1231
- align_of_body ,
1225
+ align_to_body ,
1232
1226
)
1233
1227
}
1234
1228
1235
1229
/// [`TypeInfo`] derive code for enum types.
1236
1230
fn gen_enum_type_info_impl ( ctx : TypeInfoContext , e : & syn:: DataEnum ) -> proc_macro2:: TokenStream {
1237
1231
let mut all_type_hashes = vec ! [ ] ;
1238
1232
let mut all_align_hashes = vec ! [ ] ;
1239
- let mut all_align_ofs = vec ! [ ] ;
1233
+ let mut all_align_tos = vec ! [ ] ;
1240
1234
let mut all_field_types = vec ! [ ] ;
1241
1235
let mut all_repl_params = HashSet :: new ( ) ;
1242
1236
@@ -1246,7 +1240,7 @@ fn gen_enum_type_info_impl(ctx: TypeInfoContext, e: &syn::DataEnum) -> proc_macr
1246
1240
let mut type_hash = quote ! { Hash :: hash( stringify!( #ident) , hasher) ; } ;
1247
1241
let mut field_types = vec ! [ ] ;
1248
1242
let mut align_hash = quote ! { } ;
1249
- let mut align_of = quote ! { } ;
1243
+ let mut align_to = quote ! { } ;
1250
1244
1251
1245
match & variant. fields {
1252
1246
syn:: Fields :: Unit => { }
@@ -1268,9 +1262,9 @@ fn gen_enum_type_info_impl(ctx: TypeInfoContext, e: &syn::DataEnum) -> proc_macr
1268
1262
<#field_type_ts as AlignHash >:: align_hash( hasher, offset_of) ;
1269
1263
} ] ) ;
1270
1264
1271
- align_of . extend ( [ quote ! {
1272
- if align_of < <#field_type as AlignTo >:: align_to( ) {
1273
- align_of = <#field_type as AlignTo >:: align_to( ) ;
1265
+ align_to . extend ( [ quote ! {
1266
+ if align_to < <#field_type as AlignTo >:: align_to( ) {
1267
+ align_to = <#field_type as AlignTo >:: align_to( ) ;
1274
1268
}
1275
1269
} ] ) ;
1276
1270
@@ -1302,9 +1296,9 @@ fn gen_enum_type_info_impl(ctx: TypeInfoContext, e: &syn::DataEnum) -> proc_macr
1302
1296
<#field_type_ts as AlignHash >:: align_hash( hasher, offset_of) ;
1303
1297
} ] ) ;
1304
1298
1305
- align_of . extend ( [ quote ! {
1306
- if align_of < <#field_type as AlignTo >:: align_to( ) {
1307
- align_of = <#field_type as AlignTo >:: align_to( ) ;
1299
+ align_to . extend ( [ quote ! {
1300
+ if align_to < <#field_type as AlignTo >:: align_to( ) {
1301
+ align_to = <#field_type as AlignTo >:: align_to( ) ;
1308
1302
}
1309
1303
} ] ) ;
1310
1304
@@ -1322,25 +1316,25 @@ fn gen_enum_type_info_impl(ctx: TypeInfoContext, e: &syn::DataEnum) -> proc_macr
1322
1316
1323
1317
all_type_hashes. push ( type_hash) ;
1324
1318
all_align_hashes. push ( align_hash) ;
1325
- all_align_ofs . push ( align_of ) ;
1319
+ all_align_tos . push ( align_to ) ;
1326
1320
all_field_types. extend ( field_types) ;
1327
1321
}
1328
1322
1329
- let ( where_clause_type_hash, where_clause_align_hash, where_clause_align_of ) =
1323
+ let ( where_clause_type_hash, where_clause_align_hash, where_clause_align_to ) =
1330
1324
gen_type_info_where_clauses ( ctx. where_clause , ctx. is_zero_copy , & all_field_types) ;
1331
1325
1332
1326
let type_hash_body = gen_type_hash_body ( & ctx, & all_type_hashes) ;
1333
1327
let align_hash_body = gen_enum_align_hash_body ( & ctx, & all_align_hashes) ;
1334
- let align_of_body = quote ! {
1335
- let mut align_of = core:: mem:: align_of:: <Self >( ) ;
1328
+ let align_to_body = quote ! {
1329
+ let mut align_to = core:: mem:: align_of:: <Self >( ) ;
1336
1330
#(
1337
- #all_align_ofs
1331
+ #all_align_tos
1338
1332
) *
1339
- align_of
1333
+ align_to
1340
1334
} ;
1341
1335
1342
- let align_of_body = if ctx. is_zero_copy {
1343
- Some ( align_of_body )
1336
+ let align_to_body = if ctx. is_zero_copy {
1337
+ Some ( align_to_body )
1344
1338
} else {
1345
1339
None
1346
1340
} ;
@@ -1349,10 +1343,10 @@ fn gen_enum_type_info_impl(ctx: TypeInfoContext, e: &syn::DataEnum) -> proc_macr
1349
1343
ctx,
1350
1344
where_clause_type_hash,
1351
1345
where_clause_align_hash,
1352
- where_clause_align_of ,
1346
+ where_clause_align_to ,
1353
1347
type_hash_body,
1354
1348
align_hash_body,
1355
- align_of_body ,
1349
+ align_to_body ,
1356
1350
)
1357
1351
}
1358
1352
0 commit comments