@@ -620,9 +620,7 @@ fn convert_field<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
620
620
struct_generics : & ty:: Generics < ' tcx > ,
621
621
struct_predicates : & ty:: GenericPredicates < ' tcx > ,
622
622
v : & ast:: StructField ,
623
- ty_f : & ' tcx ty:: FieldDef_ < ' tcx , ' tcx > ,
624
- origin : ast:: DefId )
625
- -> ty:: FieldTy
623
+ ty_f : & ' tcx ty:: FieldDef_ < ' tcx , ' tcx > )
626
624
{
627
625
let tt = ccx. icx ( struct_predicates) . to_ty ( & ExplicitRscope , & * v. node . ty ) ;
628
626
ty_f. fulfill_ty ( tt) ;
@@ -636,25 +634,6 @@ fn convert_field<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
636
634
} ) ;
637
635
ccx. tcx . predicates . borrow_mut ( ) . insert ( local_def ( v. node . id ) ,
638
636
struct_predicates. clone ( ) ) ;
639
-
640
- match v. node . kind {
641
- ast:: NamedField ( ident, visibility) => {
642
- ty:: FieldTy {
643
- name : ident. name ,
644
- id : local_def ( v. node . id ) ,
645
- vis : visibility,
646
- origin : origin,
647
- }
648
- }
649
- ast:: UnnamedField ( visibility) => {
650
- ty:: FieldTy {
651
- name : special_idents:: unnamed_field. name ,
652
- id : local_def ( v. node . id ) ,
653
- vis : visibility,
654
- origin : origin,
655
- }
656
- }
657
- }
658
637
}
659
638
660
639
fn convert_associated_const < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
@@ -1018,7 +997,11 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
1018
997
write_ty_to_tcx ( tcx, it. id , scheme. ty ) ;
1019
998
1020
999
let variant = tcx. lookup_adt_def ( local_def ( it. id ) ) . struct_variant ( ) ;
1021
- convert_struct_variant_types ( ccx, & struct_def, variant, & scheme, & predicates) ;
1000
+
1001
+ for ( f, ty_f) in struct_def. fields . iter ( ) . zip ( variant. fields . iter ( ) ) {
1002
+ convert_field ( ccx, & scheme. generics , & predicates, f, ty_f)
1003
+ }
1004
+
1022
1005
if let Some ( ctor_id) = struct_def. ctor_id {
1023
1006
convert_variant_ctor ( tcx, ctor_id, variant, scheme, predicates) ;
1024
1007
}
@@ -1065,17 +1048,6 @@ fn convert_variant_ctor<'a, 'tcx>(tcx: &ty::ctxt<'tcx>,
1065
1048
} ) ;
1066
1049
}
1067
1050
1068
- fn convert_struct_variant_types < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
1069
- def : & ast:: StructDef ,
1070
- variant : & ' tcx ty:: VariantDef_ < ' tcx , ' tcx > ,
1071
- scheme : & ty:: TypeScheme < ' tcx > ,
1072
- predicates : & ty:: GenericPredicates < ' tcx > ) {
1073
- let field_tys = def. fields . iter ( ) . zip ( variant. fields . iter ( ) ) . map ( |( f, ty_f) | {
1074
- convert_field ( ccx, & scheme. generics , & predicates, f, ty_f, variant. did )
1075
- } ) . collect ( ) ;
1076
- ccx. tcx . struct_fields . borrow_mut ( ) . insert ( variant. did , Rc :: new ( field_tys) ) ;
1077
- }
1078
-
1079
1051
fn convert_enum_variant_types < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
1080
1052
def : & ' tcx ty:: ADTDef_ < ' tcx , ' tcx > ,
1081
1053
scheme : ty:: TypeScheme < ' tcx > ,
@@ -1084,7 +1056,7 @@ fn convert_enum_variant_types<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
1084
1056
let tcx = ccx. tcx ;
1085
1057
let icx = ccx. icx ( & predicates) ;
1086
1058
1087
- // Create a set of parameter types shared among all the variants.
1059
+ // fill the field types
1088
1060
for ( variant, ty_variant) in variants. iter ( ) . zip ( def. variants . iter ( ) ) {
1089
1061
match variant. node . kind {
1090
1062
ast:: TupleVariantKind ( ref args) => {
@@ -1096,10 +1068,14 @@ fn convert_enum_variant_types<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
1096
1068
}
1097
1069
1098
1070
ast:: StructVariantKind ( ref struct_def) => {
1099
- convert_struct_variant_types ( ccx, & struct_def, ty_variant, & scheme, & predicates) ;
1071
+ for ( f, ty_f) in struct_def. fields . iter ( ) . zip ( ty_variant. fields . iter ( ) ) {
1072
+ convert_field ( ccx, & scheme. generics , & predicates, f, ty_f)
1073
+ }
1100
1074
}
1101
1075
} ;
1102
1076
1077
+ // Convert the ctor, if any. This also registers the variant as
1078
+ // an item.
1103
1079
convert_variant_ctor (
1104
1080
tcx,
1105
1081
variant. node . id ,
0 commit comments