@@ -865,24 +865,6 @@ impl CodeGenerator for TemplateInstantiation {
865
865
}
866
866
}
867
867
868
- /// Generates an infinite number of anonymous field names.
869
- struct AnonFieldNames ( usize ) ;
870
-
871
- impl Default for AnonFieldNames {
872
- fn default ( ) -> AnonFieldNames {
873
- AnonFieldNames ( 0 )
874
- }
875
- }
876
-
877
- impl Iterator for AnonFieldNames {
878
- type Item = String ;
879
-
880
- fn next ( & mut self ) -> Option < String > {
881
- self . 0 += 1 ;
882
- Some ( format ! ( "__bindgen_anon_{}" , self . 0 ) )
883
- }
884
- }
885
-
886
868
/// Trait for implementing the code generation of a struct or union field.
887
869
trait FieldCodegen < ' a > {
888
870
type Extra ;
@@ -894,7 +876,6 @@ trait FieldCodegen<'a> {
894
876
codegen_depth : usize ,
895
877
accessor_kind : FieldAccessorKind ,
896
878
parent : & CompInfo ,
897
- anon_field_names : & mut AnonFieldNames ,
898
879
result : & mut CodegenResult ,
899
880
struct_layout : & mut StructLayoutTracker ,
900
881
fields : & mut F ,
@@ -915,7 +896,6 @@ impl<'a> FieldCodegen<'a> for Field {
915
896
codegen_depth : usize ,
916
897
accessor_kind : FieldAccessorKind ,
917
898
parent : & CompInfo ,
918
- anon_field_names : & mut AnonFieldNames ,
919
899
result : & mut CodegenResult ,
920
900
struct_layout : & mut StructLayoutTracker ,
921
901
fields : & mut F ,
@@ -933,7 +913,6 @@ impl<'a> FieldCodegen<'a> for Field {
933
913
codegen_depth,
934
914
accessor_kind,
935
915
parent,
936
- anon_field_names,
937
916
result,
938
917
struct_layout,
939
918
fields,
@@ -948,7 +927,6 @@ impl<'a> FieldCodegen<'a> for Field {
948
927
codegen_depth,
949
928
accessor_kind,
950
929
parent,
951
- anon_field_names,
952
930
result,
953
931
struct_layout,
954
932
fields,
@@ -970,7 +948,6 @@ impl<'a> FieldCodegen<'a> for FieldData {
970
948
codegen_depth : usize ,
971
949
accessor_kind : FieldAccessorKind ,
972
950
parent : & CompInfo ,
973
- anon_field_names : & mut AnonFieldNames ,
974
951
result : & mut CodegenResult ,
975
952
struct_layout : & mut StructLayoutTracker ,
976
953
fields : & mut F ,
@@ -1030,7 +1007,7 @@ impl<'a> FieldCodegen<'a> for FieldData {
1030
1007
let field_name =
1031
1008
self . name ( )
1032
1009
. map ( |name| ctx. rust_mangle ( name) . into_owned ( ) )
1033
- . unwrap_or_else ( || anon_field_names . next ( ) . unwrap ( ) ) ;
1010
+ . expect ( "Each field should have a name in codegen!" ) ;
1034
1011
let field_ident = ctx. rust_ident_raw ( field_name. as_str ( ) ) ;
1035
1012
1036
1013
if !parent. is_union ( ) {
@@ -1164,7 +1141,6 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
1164
1141
codegen_depth : usize ,
1165
1142
accessor_kind : FieldAccessorKind ,
1166
1143
parent : & CompInfo ,
1167
- anon_field_names : & mut AnonFieldNames ,
1168
1144
result : & mut CodegenResult ,
1169
1145
struct_layout : & mut StructLayoutTracker ,
1170
1146
fields : & mut F ,
@@ -1213,7 +1189,6 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
1213
1189
codegen_depth,
1214
1190
accessor_kind,
1215
1191
parent,
1216
- anon_field_names,
1217
1192
result,
1218
1193
struct_layout,
1219
1194
fields,
@@ -1321,7 +1296,6 @@ impl<'a> FieldCodegen<'a> for Bitfield {
1321
1296
_codegen_depth : usize ,
1322
1297
_accessor_kind : FieldAccessorKind ,
1323
1298
parent : & CompInfo ,
1324
- _anon_field_names : & mut AnonFieldNames ,
1325
1299
_result : & mut CodegenResult ,
1326
1300
_struct_layout : & mut StructLayoutTracker ,
1327
1301
_fields : & mut F ,
@@ -1595,7 +1569,6 @@ impl CodeGenerator for CompInfo {
1595
1569
1596
1570
let mut methods = vec ! [ ] ;
1597
1571
if !is_opaque {
1598
- let mut anon_field_names = AnonFieldNames :: default ( ) ;
1599
1572
let codegen_depth = item. codegen_depth ( ctx) ;
1600
1573
let fields_should_be_private =
1601
1574
item. annotations ( ) . private_fields ( ) . unwrap_or ( false ) ;
@@ -1609,7 +1582,6 @@ impl CodeGenerator for CompInfo {
1609
1582
codegen_depth,
1610
1583
struct_accessor_kind,
1611
1584
self ,
1612
- & mut anon_field_names,
1613
1585
result,
1614
1586
& mut struct_layout,
1615
1587
& mut fields,
0 commit comments