@@ -990,6 +990,15 @@ fn check_type_defn<'tcx, F>(
990990 let packed = tcx. adt_def ( item. def_id ) . repr ( ) . packed ( ) ;
991991
992992 for variant in & variants {
993+ // All field types must be well-formed.
994+ for field in & variant. fields {
995+ fcx. register_wf_obligation (
996+ field. ty . into ( ) ,
997+ field. span ,
998+ ObligationCauseCode :: WellFormed ( Some ( WellFormedLoc :: Ty ( field. def_id ) ) ) ,
999+ )
1000+ }
1001+
9931002 // For DST, or when drop needs to copy things around, all
9941003 // intermediate types must be sized.
9951004 let needs_drop_copy = || {
@@ -1006,6 +1015,7 @@ fn check_type_defn<'tcx, F>(
10061015 }
10071016 }
10081017 } ;
1018+ // All fields (except for possibly the last) should be sized.
10091019 let all_sized = all_sized || variant. fields . is_empty ( ) || needs_drop_copy ( ) ;
10101020 let unsized_len = if all_sized { 0 } else { 1 } ;
10111021 for ( idx, field) in
@@ -1030,15 +1040,6 @@ fn check_type_defn<'tcx, F>(
10301040 ) ;
10311041 }
10321042
1033- // All field types must be well-formed.
1034- for field in & variant. fields {
1035- fcx. register_wf_obligation (
1036- field. ty . into ( ) ,
1037- field. span ,
1038- ObligationCauseCode :: WellFormed ( Some ( WellFormedLoc :: Ty ( field. def_id ) ) ) ,
1039- )
1040- }
1041-
10421043 // Explicit `enum` discriminant values must const-evaluate successfully.
10431044 if let Some ( discr_def_id) = variant. explicit_discr {
10441045 let discr_substs = InternalSubsts :: identity_for_item ( tcx, discr_def_id. to_def_id ( ) ) ;
0 commit comments