@@ -23,25 +23,25 @@ struct CommonDeriveInput {
23
23
/// The identifier of the struct.
24
24
name : syn:: Ident ,
25
25
/// The token stream to be used after `impl` in angle brackets. It contains
26
- /// the generics , lifetimes, and consts , with their trait bounds.
26
+ /// the generic types , lifetimes, and constants , with their trait bounds.
27
27
generics : proc_macro2:: TokenStream ,
28
28
/// A vector containing the identifiers of the generics.
29
29
generics_name_vec : Vec < proc_macro2:: TokenStream > ,
30
30
/// Same as `generics_name_vec`, but names are concatenated
31
- /// and separated by commans .
31
+ /// and separated by commas .
32
32
generics_names : proc_macro2:: TokenStream ,
33
33
/// A vector containing the name of generics types, represented as strings.
34
- generics_names_raw : Vec < String > ,
35
- /// The where clause.
36
- where_clause : proc_macro2:: TokenStream ,
37
- /// A vector containing the identifier of the constants, represented as strings.
38
- /// Used to include the const values into the type hash.
39
- //const_names_raw: Vec<String>,
34
+ /// Used to include the identifiers of generic types into the type hash.
35
+ type_names_raw : Vec < String > ,
40
36
/// A vector containing the identifiers of the generic constants.
37
+ /// Used to include the generic constant values into the type hash.
41
38
const_names_vec : Vec < syn:: Ident > ,
42
- /// A vector containing the identifier of the constants, represented as strings.
43
- /// Used to include the const values into the type hash.
39
+ /// A vector containing the identifier of the generic constants, represented
40
+ /// as strings. Used to include the identifiers of generic constants into
41
+ /// the type hash.
44
42
const_names_raw : Vec < String > ,
43
+ /// The where clause.
44
+ where_clause : proc_macro2:: TokenStream ,
45
45
}
46
46
47
47
impl CommonDeriveInput {
@@ -51,7 +51,7 @@ impl CommonDeriveInput {
51
51
fn new ( input : DeriveInput , traits_to_add : Vec < syn:: Path > ) -> Self {
52
52
let name = input. ident ;
53
53
let mut generics = quote ! ( ) ;
54
- let mut generics_names_raw = vec ! [ ] ;
54
+ let mut type_names_raw = vec ! [ ] ;
55
55
let mut generics_name_vec = vec ! [ ] ;
56
56
let mut generics_names = quote ! ( ) ;
57
57
@@ -63,7 +63,7 @@ impl CommonDeriveInput {
63
63
match x {
64
64
syn:: GenericParam :: Type ( mut t) => {
65
65
generics_names. extend ( t. ident . to_token_stream ( ) ) ;
66
- generics_names_raw . push ( t. ident . to_string ( ) ) ;
66
+ type_names_raw . push ( t. ident . to_string ( ) ) ;
67
67
68
68
t. default = None ;
69
69
for trait_to_add in traits_to_add. iter ( ) {
@@ -92,7 +92,6 @@ impl CommonDeriveInput {
92
92
generics. extend ( quote ! ( #c, ) ) ;
93
93
generics_name_vec. push ( c. ident . to_token_stream ( ) ) ;
94
94
const_names_vec. push ( c. ident . clone ( ) ) ;
95
- const_names_raw. push ( c. ident . to_string ( ) ) ;
96
95
}
97
96
} ;
98
97
generics_names. extend ( quote ! ( , ) )
@@ -111,7 +110,7 @@ impl CommonDeriveInput {
111
110
generics,
112
111
generics_names,
113
112
where_clause,
114
- generics_names_raw ,
113
+ type_names_raw ,
115
114
generics_name_vec,
116
115
const_names_raw,
117
116
const_names_vec,
@@ -176,7 +175,7 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
176
175
let CommonDeriveInput {
177
176
name,
178
177
generics_names,
179
- generics_names_raw ,
178
+ type_names_raw ,
180
179
generics_name_vec,
181
180
generics,
182
181
..
@@ -212,7 +211,7 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
212
211
. map ( |x| x. to_token_stream ( ) )
213
212
. unwrap_or_else ( || syn:: Index :: from ( field_idx) . to_token_stream ( ) ) ;
214
213
215
- if generics_names_raw . contains ( & ty. to_token_stream ( ) . to_string ( ) ) {
214
+ if type_names_raw . contains ( & ty. to_token_stream ( ) . to_string ( ) ) {
216
215
generic_fields. push ( field_name. clone ( ) ) ;
217
216
generic_types. push ( ty) ;
218
217
} else {
@@ -229,7 +228,7 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
229
228
230
229
s. fields . iter ( ) . for_each ( |field| {
231
230
let ty = & field. ty ;
232
- if generics_names_raw . contains ( & ty. to_token_stream ( ) . to_string ( ) ) {
231
+ if type_names_raw . contains ( & ty. to_token_stream ( ) . to_string ( ) ) {
233
232
methods. push ( syn:: parse_quote!( _deserialize_eps_inner) ) ;
234
233
} else {
235
234
methods. push ( syn:: parse_quote!( _deserialize_full_inner) ) ;
@@ -479,7 +478,7 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
479
478
. iter ( )
480
479
. map ( |named| ( named. ident . as_ref ( ) . unwrap ( ) , & named. ty ) )
481
480
. for_each ( |( ident, ty) | {
482
- if generics_names_raw . contains ( & ty. to_token_stream ( ) . to_string ( ) ) {
481
+ if type_names_raw . contains ( & ty. to_token_stream ( ) . to_string ( ) ) {
483
482
generic_fields. push ( ident. to_token_stream ( ) ) ;
484
483
generic_types. push ( ty. to_token_stream ( ) ) ;
485
484
} else {
@@ -514,7 +513,7 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
514
513
bounds : bounds_des,
515
514
} ) ) ;
516
515
517
- if generics_names_raw . contains ( & ty. to_token_stream ( ) . to_string ( ) ) {
516
+ if type_names_raw . contains ( & ty. to_token_stream ( ) . to_string ( ) ) {
518
517
methods. push ( syn:: parse_quote!( _deserialize_eps_inner) ) ;
519
518
} else {
520
519
methods. push ( syn:: parse_quote!( _deserialize_full_inner) ) ;
@@ -555,7 +554,7 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
555
554
. for_each ( |( field_idx, unnamed) | {
556
555
let ty = & unnamed. ty ;
557
556
let ident = syn:: Index :: from ( field_idx) ;
558
- if generics_names_raw . contains ( & ty. to_token_stream ( ) . to_string ( ) ) {
557
+ if type_names_raw . contains ( & ty. to_token_stream ( ) . to_string ( ) ) {
559
558
generic_fields. push ( ident. to_token_stream ( ) ) ;
560
559
generic_types. push ( ty. to_token_stream ( ) ) ;
561
560
} else {
@@ -595,7 +594,7 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
595
594
bounds : bounds_des,
596
595
} ) ) ;
597
596
598
- if generics_names_raw . contains ( & ty. to_token_stream ( ) . to_string ( ) ) {
597
+ if type_names_raw . contains ( & ty. to_token_stream ( ) . to_string ( ) ) {
599
598
methods. push ( syn:: parse_quote!( _deserialize_eps_inner) ) ;
600
599
} else {
601
600
methods. push ( syn:: parse_quote!( _deserialize_full_inner) ) ;
@@ -778,7 +777,6 @@ pub fn epserde_type_hash(input: TokenStream) -> TokenStream {
778
777
generics : generics_typehash,
779
778
generics_names,
780
779
where_clause,
781
- //generics_names_raw,
782
780
const_names_vec,
783
781
const_names_raw,
784
782
..
@@ -847,10 +845,11 @@ pub fn epserde_type_hash(input: TokenStream) -> TokenStream {
847
845
use core:: hash:: Hash ;
848
846
// Hash in ZeroCopy
849
847
"ZeroCopy" . hash( hasher) ;
850
- // Hash the generic const values and names
848
+ // Hash the values of generic constants
851
849
#(
852
850
#const_names_vec. hash( hasher) ;
853
851
) *
852
+ // Hash the identifiers of generic constants
854
853
#(
855
854
#const_names_raw. hash( hasher) ;
856
855
) *
@@ -917,10 +916,11 @@ pub fn epserde_type_hash(input: TokenStream) -> TokenStream {
917
916
// No alignment, so we do not hash in anything.
918
917
// Hash in DeepCopy
919
918
"DeepCopy" . hash( hasher) ;
920
- // Hash the generic const values and names
919
+ // Hash the values of generic constants
921
920
#(
922
921
#const_names_vec. hash( hasher) ;
923
922
) *
923
+ // Hash the identifiers of generic constants
924
924
#(
925
925
#const_names_raw. hash( hasher) ;
926
926
) *
@@ -1052,10 +1052,11 @@ pub fn epserde_type_hash(input: TokenStream) -> TokenStream {
1052
1052
use core:: hash:: Hash ;
1053
1053
// Hash in ZeroCopy
1054
1054
"ZeroCopy" . hash( hasher) ;
1055
- // Hash the generic const values and names
1055
+ // Hash the values of generic constants
1056
1056
#(
1057
1057
#const_names_vec. hash( hasher) ;
1058
1058
) *
1059
+ // Hash the identifiers of generic constants
1059
1060
#(
1060
1061
#const_names_raw. hash( hasher) ;
1061
1062
) *
@@ -1114,10 +1115,11 @@ pub fn epserde_type_hash(input: TokenStream) -> TokenStream {
1114
1115
// No alignment, so we do not hash in anything.
1115
1116
// Hash in DeepCopy
1116
1117
"DeepCopy" . hash( hasher) ;
1117
- // Hash the generic const values and names
1118
+ // Hash the values of generic constants
1118
1119
#(
1119
1120
#const_names_vec. hash( hasher) ;
1120
1121
) *
1122
+ // Hash the identifiers of generic constants
1121
1123
#(
1122
1124
#const_names_raw. hash( hasher) ;
1123
1125
) *
0 commit comments