@@ -10,15 +10,15 @@ pub(crate) fn implement(cx: &Ctxt<'_>, en: &DataEnum) -> Result<TokenStream, ()>
10
10
let ident = & cx. ast . ident ;
11
11
let lt = cx. lt ;
12
12
13
- let clone = & cx. toks . clone ;
14
- let copy = & cx. toks . copy ;
15
- let default = & cx. toks . default ;
16
- let eq = & cx. toks . eq ;
17
- let key_trait = & cx. toks . key_trait ;
18
- let mem = & cx. toks . mem ;
19
- let option = & cx. toks . option ;
20
- let partial_eq = & cx. toks . partial_eq ;
21
- let storage_trait = & cx. toks . storage_trait ;
13
+ let clone_t = cx. toks . clone_t ( ) ;
14
+ let copy_t = cx. toks . copy_t ( ) ;
15
+ let default_t = cx. toks . default_t ( ) ;
16
+ let eq_t = cx. toks . eq_t ( ) ;
17
+ let key_t = cx. toks . key_t ( ) ;
18
+ let mem = cx. toks . mem ( ) ;
19
+ let option = cx. toks . option ( ) ;
20
+ let partial_eq_t = cx. toks . partial_eq_t ( ) ;
21
+ let storage_t = cx. toks . storage_t ( ) ;
22
22
23
23
let const_wrapper = Ident :: new (
24
24
& format ! ( "__IMPL_KEY_FOR_{}" , cx. ast. ident) ,
@@ -47,17 +47,17 @@ pub(crate) fn implement(cx: &Ctxt<'_>, en: &DataEnum) -> Result<TokenStream, ()>
47
47
let var = & variant. ident ;
48
48
let name = Ident :: new ( & format ! ( "f{}" , index) , Span :: call_site ( ) ) ;
49
49
50
- field_inits. push ( quote ! ( #name: #default :: default ( ) ) ) ;
51
- field_clones. push ( quote ! ( #name: #clone :: clone( & self . #name) ) ) ;
50
+ field_inits. push ( quote ! ( #name: #default_t :: default ( ) ) ) ;
51
+ field_clones. push ( quote ! ( #name: #clone_t :: clone( & self . #name) ) ) ;
52
52
53
53
field_partial_eqs. push ( quote ! {
54
- if #partial_eq :: ne( & self . #name, & other. #name) {
54
+ if #partial_eq_t :: ne( & self . #name, & other. #name) {
55
55
return false ;
56
56
}
57
57
} ) ;
58
58
59
59
field_partial_not_eqs. push ( quote ! {
60
- if #partial_eq :: ne( & self . #name, & other. #name) {
60
+ if #partial_eq_t :: ne( & self . #name, & other. #name) {
61
61
return true ;
62
62
}
63
63
} ) ;
@@ -75,7 +75,7 @@ pub(crate) fn implement(cx: &Ctxt<'_>, en: &DataEnum) -> Result<TokenStream, ()>
75
75
insert. push ( quote ! ( #mem:: replace( & mut self . #name, #option:: Some ( value) ) ) ) ;
76
76
remove. push ( quote ! ( #mem:: replace( & mut self . #name, #option:: None ) ) ) ;
77
77
retain. push ( quote ! {
78
- if let Some ( val) = #option:: as_mut( & mut self . #name) {
78
+ if let #option :: Some ( val) = #option:: as_mut( & mut self . #name) {
79
79
if !func( #ident:: #var, val) {
80
80
self . #name = None ;
81
81
}
@@ -94,8 +94,8 @@ pub(crate) fn implement(cx: &Ctxt<'_>, en: &DataEnum) -> Result<TokenStream, ()>
94
94
}
95
95
96
96
let element = unnamed. unnamed . first ( ) . expect ( "Expected one element" ) ;
97
- let storage = quote ! ( <#element as #key_trait >:: Storage :: <V >) ;
98
- let as_storage = quote ! ( <#storage as #storage_trait <#element, V >>) ;
97
+ let storage = quote ! ( <#element as #key_t >:: Storage :: <V >) ;
98
+ let as_storage = quote ! ( <#storage as #storage_t <#element, V >>) ;
99
99
100
100
len. push ( quote ! ( #as_storage:: len( & self . #name) ) ) ;
101
101
is_empty. push ( quote ! ( #as_storage:: is_empty( & self . #name) ) ) ;
@@ -113,7 +113,7 @@ pub(crate) fn implement(cx: &Ctxt<'_>, en: &DataEnum) -> Result<TokenStream, ()>
113
113
#as_storage:: retain( & mut self . #name, |k, v| func( #ident:: #var( k) , v) ) ;
114
114
} ) ;
115
115
116
- copy_bounds. push ( quote ! ( #storage: #copy ) ) ;
116
+ copy_bounds. push ( quote ! ( #storage: #copy_t ) ) ;
117
117
118
118
FieldKind :: Complex {
119
119
element : quote ! ( #element) ,
@@ -139,7 +139,7 @@ pub(crate) fn implement(cx: &Ctxt<'_>, en: &DataEnum) -> Result<TokenStream, ()>
139
139
let mut iter_clone = Vec :: new ( ) ;
140
140
141
141
for FieldSpec { name, .. } in & field_specs {
142
- iter_clone. push ( quote ! ( #name: #clone :: clone( & self . #name) ) ) ;
142
+ iter_clone. push ( quote ! ( #name: #clone_t :: clone( & self . #name) ) ) ;
143
143
}
144
144
145
145
let pattern = & pattern;
@@ -165,7 +165,7 @@ pub(crate) fn implement(cx: &Ctxt<'_>, en: &DataEnum) -> Result<TokenStream, ()>
165
165
}
166
166
167
167
#[ automatically_derived]
168
- impl <V > #clone for Storage <V > where V : #clone {
168
+ impl <V > #clone_t for Storage <V > where V : #clone_t {
169
169
#[ inline]
170
170
fn clone( & self ) -> Storage <V > {
171
171
Storage {
@@ -175,10 +175,10 @@ pub(crate) fn implement(cx: &Ctxt<'_>, en: &DataEnum) -> Result<TokenStream, ()>
175
175
}
176
176
177
177
#[ automatically_derived]
178
- impl <V > #copy for Storage <V > where V : #copy , #( #copy_bounds, ) * { }
178
+ impl <V > #copy_t for Storage <V > where V : #copy_t , #( #copy_bounds, ) * { }
179
179
180
180
#[ automatically_derived]
181
- impl <V > #partial_eq for Storage <V > where V : #partial_eq {
181
+ impl <V > #partial_eq_t for Storage <V > where V : #partial_eq_t {
182
182
#[ inline]
183
183
fn eq( & self , other: & Storage <V >) -> bool {
184
184
#( #field_partial_eqs; ) *
@@ -193,10 +193,10 @@ pub(crate) fn implement(cx: &Ctxt<'_>, en: &DataEnum) -> Result<TokenStream, ()>
193
193
}
194
194
195
195
#[ automatically_derived]
196
- impl <V > #eq for Storage <V > where V : #eq { }
196
+ impl <V > #eq_t for Storage <V > where V : #eq_t { }
197
197
198
198
#[ automatically_derived]
199
- impl <V > #default for Storage <V > {
199
+ impl <V > #default_t for Storage <V > {
200
200
#[ inline]
201
201
fn default ( ) -> Self {
202
202
Self {
@@ -206,7 +206,7 @@ pub(crate) fn implement(cx: &Ctxt<'_>, en: &DataEnum) -> Result<TokenStream, ()>
206
206
}
207
207
208
208
#[ automatically_derived]
209
- impl <V > #storage_trait <#ident, V > for Storage <V > {
209
+ impl <V > #storage_t <#ident, V > for Storage <V > {
210
210
type Iter <#lt> = Iter <#lt, V > where V : #lt;
211
211
type Keys <#lt> = Keys <#lt, V > where V : #lt;
212
212
type Values <#lt> = Values <#lt, V > where V : #lt;
@@ -328,7 +328,7 @@ pub(crate) fn implement(cx: &Ctxt<'_>, en: &DataEnum) -> Result<TokenStream, ()>
328
328
}
329
329
330
330
#[ automatically_derived]
331
- impl #key_trait for #ident {
331
+ impl #key_t for #ident {
332
332
type Storage <V > = Storage <V >;
333
333
}
334
334
@@ -353,9 +353,9 @@ fn build_iter_next(
353
353
assoc_type : & Ident ,
354
354
lt : Option < & syn:: Lifetime > ,
355
355
) -> Result < ( ) , ( ) > {
356
- let option = & cx. toks . option ;
357
- let iterator_t = & cx. toks . iterator_t ;
358
- let double_ended_iterator_t = & cx. toks . double_ended_iterator_t ;
356
+ let option = cx. toks . option ( ) ;
357
+ let iterator_t = cx. toks . iterator_t ( ) ;
358
+ let double_ended_iterator_t = cx. toks . double_ended_iterator_t ( ) ;
359
359
let ident = & cx. ast . ident ;
360
360
361
361
for FieldSpec {
@@ -431,13 +431,14 @@ fn build_iter_impl(
431
431
let type_name = syn:: Ident :: new ( id, Span :: call_site ( ) ) ;
432
432
433
433
let lt = cx. lt ;
434
- let option = & cx. toks . option ;
435
- let iterator_t = & cx. toks . iterator_t ;
436
- let double_ended_iterator_t = & cx. toks . double_ended_iterator_t ;
437
- let clone = & cx. toks . clone ;
438
434
let ident = & cx. ast . ident ;
439
435
let vis = & cx. ast . vis ;
440
436
437
+ let option = cx. toks . option ( ) ;
438
+ let iterator_t = cx. toks . iterator_t ( ) ;
439
+ let double_ended_iterator_t = cx. toks . double_ended_iterator_t ( ) ;
440
+ let clone_t = cx. toks . clone_t ( ) ;
441
+
441
442
let mut step_forward = IteratorNext :: default ( ) ;
442
443
let mut step_backward = IteratorNextBack :: default ( ) ;
443
444
@@ -455,7 +456,7 @@ fn build_iter_impl(
455
456
) ?;
456
457
457
458
for FieldSpec { name, kind, .. } in field_specs {
458
- iter_clone. push ( quote ! ( #name: #clone :: clone( & self . #name) ) ) ;
459
+ iter_clone. push ( quote ! ( #name: #clone_t :: clone( & self . #name) ) ) ;
459
460
460
461
match kind {
461
462
FieldKind :: Simple => {
@@ -484,7 +485,7 @@ fn build_iter_impl(
484
485
}
485
486
486
487
#[ automatically_derived]
487
- impl <#lt, V > #clone for #type_name<#lt, V > where V : #lt {
488
+ impl <#lt, V > #clone_t for #type_name<#lt, V > where V : #lt {
488
489
#[ inline]
489
490
fn clone( & self ) -> Self {
490
491
Self {
@@ -528,15 +529,16 @@ fn build_keys_impl(
528
529
let type_name = syn:: Ident :: new ( id, Span :: call_site ( ) ) ;
529
530
530
531
let lt = cx. lt ;
531
- let option = & cx. toks . option ;
532
- let iterator_t = & cx. toks . iterator_t ;
533
- let double_ended_iterator_t = & cx. toks . double_ended_iterator_t ;
534
- let clone = & cx. toks . clone ;
535
- let bool_type = & cx. toks . bool_type ;
536
- let mem = & cx. toks . mem ;
537
532
let ident = & cx. ast . ident ;
538
533
let vis = & cx. ast . vis ;
539
534
535
+ let bool_type = cx. toks . bool_type ( ) ;
536
+ let clone_t = cx. toks . clone_t ( ) ;
537
+ let double_ended_iterator_t = cx. toks . double_ended_iterator_t ( ) ;
538
+ let iterator_t = cx. toks . iterator_t ( ) ;
539
+ let mem = cx. toks . mem ( ) ;
540
+ let option = cx. toks . option ( ) ;
541
+
540
542
let mut step_forward = IteratorNext :: default ( ) ;
541
543
let mut step_backward = IteratorNextBack :: default ( ) ;
542
544
@@ -553,7 +555,7 @@ fn build_keys_impl(
553
555
..
554
556
} in field_specs
555
557
{
556
- iter_clone. push ( quote ! ( #name: #clone :: clone( & self . #name) ) ) ;
558
+ iter_clone. push ( quote ! ( #name: #clone_t :: clone( & self . #name) ) ) ;
557
559
558
560
match kind {
559
561
FieldKind :: Simple => {
@@ -622,7 +624,7 @@ fn build_keys_impl(
622
624
}
623
625
624
626
#[ automatically_derived]
625
- impl <#lt, V > #clone for #type_name<#lt, V > where V : #lt {
627
+ impl <#lt, V > #clone_t for #type_name<#lt, V > where V : #lt {
626
628
#[ inline]
627
629
fn clone( & self ) -> Self {
628
630
Self {
@@ -666,12 +668,13 @@ fn build_values_impl(
666
668
let type_name = syn:: Ident :: new ( id, Span :: call_site ( ) ) ;
667
669
668
670
let lt = cx. lt ;
669
- let option = & cx. toks . option ;
670
- let iterator_t = & cx. toks . iterator_t ;
671
- let double_ended_iterator_t = & cx. toks . double_ended_iterator_t ;
672
- let clone = & cx. toks . clone ;
673
671
let vis = & cx. ast . vis ;
674
672
673
+ let clone_t = cx. toks . clone_t ( ) ;
674
+ let double_ended_iterator_t = cx. toks . double_ended_iterator_t ( ) ;
675
+ let iterator_t = cx. toks . iterator_t ( ) ;
676
+ let option = cx. toks . option ( ) ;
677
+
675
678
let mut step_forward = IteratorNext :: default ( ) ;
676
679
let mut step_backward = IteratorNextBack :: default ( ) ;
677
680
@@ -687,7 +690,7 @@ fn build_values_impl(
687
690
..
688
691
} in field_specs
689
692
{
690
- iter_clone. push ( quote ! ( #name: #clone :: clone( & self . #name) ) ) ;
693
+ iter_clone. push ( quote ! ( #name: #clone_t :: clone( & self . #name) ) ) ;
691
694
692
695
match kind {
693
696
FieldKind :: Simple => {
@@ -756,7 +759,7 @@ fn build_values_impl(
756
759
}
757
760
758
761
#[ automatically_derived]
759
- impl <#lt, V > #clone for #type_name<#lt, V > where V : #lt {
762
+ impl <#lt, V > #clone_t for #type_name<#lt, V > where V : #lt {
760
763
#[ inline]
761
764
fn clone( & self ) -> Self {
762
765
Self {
@@ -799,12 +802,13 @@ fn build_iter_mut_impl(
799
802
) -> Result < ( TokenStream , Vec < TokenStream > ) , ( ) > {
800
803
let type_name = syn:: Ident :: new ( id, Span :: call_site ( ) ) ;
801
804
802
- let lt = cx. lt ;
803
805
let ident = & cx. ast . ident ;
806
+ let lt = cx. lt ;
804
807
let vis = & cx. ast . vis ;
805
- let iterator_t = & cx. toks . iterator_t ;
806
- let double_ended_iterator_t = & cx. toks . double_ended_iterator_t ;
807
- let option = & cx. toks . option ;
808
+
809
+ let double_ended_iterator_t = cx. toks . double_ended_iterator_t ( ) ;
810
+ let iterator_t = cx. toks . iterator_t ( ) ;
811
+ let option = cx. toks . option ( ) ;
808
812
809
813
let mut step_forward = IteratorNext :: default ( ) ;
810
814
let mut step_backward = IteratorNextBack :: default ( ) ;
@@ -885,11 +889,12 @@ fn build_values_mut_impl(
885
889
let type_name = syn:: Ident :: new ( id, Span :: call_site ( ) ) ;
886
890
887
891
let lt = cx. lt ;
888
- let option = & cx. toks . option ;
889
- let iterator_t = & cx. toks . iterator_t ;
890
- let clone = & cx. toks . clone ;
891
892
let vis = & cx. ast . vis ;
892
- let double_ended_iterator_t = & cx. toks . double_ended_iterator_t ;
893
+
894
+ let option = cx. toks . option ( ) ;
895
+ let iterator_t = cx. toks . iterator_t ( ) ;
896
+ let clone_t = cx. toks . clone_t ( ) ;
897
+ let double_ended_iterator_t = cx. toks . double_ended_iterator_t ( ) ;
893
898
894
899
let mut step_forward = IteratorNext :: default ( ) ;
895
900
let mut step_backward = IteratorNextBack :: default ( ) ;
@@ -906,7 +911,7 @@ fn build_values_mut_impl(
906
911
..
907
912
} in field_specs
908
913
{
909
- iter_clone. push ( quote ! ( #name: #clone :: clone( & self . #name) ) ) ;
914
+ iter_clone. push ( quote ! ( #name: #clone_t :: clone( & self . #name) ) ) ;
910
915
911
916
match kind {
912
917
FieldKind :: Simple => {
@@ -1008,10 +1013,11 @@ fn build_into_iter_impl(
1008
1013
1009
1014
let ident = & cx. ast . ident ;
1010
1015
let vis = & cx. ast . vis ;
1011
- let option = & cx. toks . option ;
1012
- let clone = & cx. toks . clone ;
1013
- let iterator_t = & cx. toks . iterator_t ;
1014
- let double_ended_iterator_t = & cx. toks . double_ended_iterator_t ;
1016
+
1017
+ let option = cx. toks . option ( ) ;
1018
+ let clone_t = cx. toks . clone_t ( ) ;
1019
+ let iterator_t = cx. toks . iterator_t ( ) ;
1020
+ let double_ended_iterator_t = cx. toks . double_ended_iterator_t ( ) ;
1015
1021
1016
1022
let mut step_forward = IteratorNext :: default ( ) ;
1017
1023
let mut step_backward = IteratorNextBack :: default ( ) ;
@@ -1031,7 +1037,7 @@ fn build_into_iter_impl(
1031
1037
) ?;
1032
1038
1033
1039
for FieldSpec { name, kind, .. } in field_specs {
1034
- field_clone. push ( quote ! ( #name: #clone :: clone( & self . #name) ) ) ;
1040
+ field_clone. push ( quote ! ( #name: #clone_t :: clone( & self . #name) ) ) ;
1035
1041
1036
1042
match kind {
1037
1043
FieldKind :: Simple => {
@@ -1045,7 +1051,7 @@ fn build_into_iter_impl(
1045
1051
} => {
1046
1052
field_decls. push ( quote ! ( #name: #as_storage:: IntoIter ) ) ;
1047
1053
init. push ( quote ! ( #name: #storage:: into_iter( self . #name) ) ) ;
1048
- clone_bounds. push ( quote ! ( #as_storage:: IntoIter : #clone ) ) ;
1054
+ clone_bounds. push ( quote ! ( #as_storage:: IntoIter : #clone_t ) ) ;
1049
1055
}
1050
1056
}
1051
1057
}
@@ -1060,7 +1066,7 @@ fn build_into_iter_impl(
1060
1066
}
1061
1067
1062
1068
#[ automatically_derived]
1063
- impl <V > #clone for #type_name<V > where V : Clone , #( #clone_bounds, ) * {
1069
+ impl <V > #clone_t for #type_name<V > where V : Clone , #( #clone_bounds, ) * {
1064
1070
#[ inline]
1065
1071
fn clone( & self ) -> Self {
1066
1072
Self {
@@ -1157,14 +1163,15 @@ fn build_entry_impl(cx: &Ctxt<'_>, field_specs: &[FieldSpec<'_>]) -> Result<Toke
1157
1163
let ident = & cx. ast . ident ;
1158
1164
let vis = & cx. ast . vis ;
1159
1165
let lt = cx. lt ;
1160
- let option = & cx. toks . option ;
1161
- let storage_entry_trait = & cx. toks . storage_entry_trait ;
1162
- let occupied_entry_trait = & cx. toks . occupied_entry_trait ;
1163
- let vacant_entry_trait = & cx. toks . vacant_entry_trait ;
1164
- let entry_enum = & cx. toks . entry_enum ;
1165
- let option_bucket_option = & cx. toks . option_bucket_option ;
1166
- let option_bucket_some = & cx. toks . option_bucket_some ;
1167
- let option_bucket_none = & cx. toks . option_bucket_none ;
1166
+
1167
+ let entry_enum = cx. toks . entry_enum ( ) ;
1168
+ let occupied_entry_trait = cx. toks . occupied_entry_t ( ) ;
1169
+ let option = cx. toks . option ( ) ;
1170
+ let option_bucket_none = cx. toks . option_bucket_none ( ) ;
1171
+ let option_bucket_option = cx. toks . option_bucket_option ( ) ;
1172
+ let option_bucket_some = cx. toks . option_bucket_some ( ) ;
1173
+ let storage_entry_trait = cx. toks . storage_entry_t ( ) ;
1174
+ let vacant_entry_trait = cx. toks . vacant_entry_t ( ) ;
1168
1175
1169
1176
let mut init = Vec :: new ( ) ;
1170
1177
let mut occupied_variant = Vec :: new ( ) ;
0 commit comments