@@ -1008,6 +1008,15 @@ fn check_type_defn<'tcx, F>(
10081008 let packed = tcx. adt_def ( item. def_id ) . repr ( ) . packed ( ) ;
10091009
10101010 for variant in & variants {
1011+ // All field types must be well-formed.
1012+ for field in & variant. fields {
1013+ fcx. register_wf_obligation (
1014+ field. ty . into ( ) ,
1015+ field. span ,
1016+ ObligationCauseCode :: WellFormed ( Some ( WellFormedLoc :: Ty ( field. def_id ) ) ) ,
1017+ )
1018+ }
1019+
10111020 // For DST, or when drop needs to copy things around, all
10121021 // intermediate types must be sized.
10131022 let needs_drop_copy = || {
@@ -1024,6 +1033,7 @@ fn check_type_defn<'tcx, F>(
10241033 }
10251034 }
10261035 } ;
1036+ // All fields (except for possibly the last) should be sized.
10271037 let all_sized = all_sized || variant. fields . is_empty ( ) || needs_drop_copy ( ) ;
10281038 let unsized_len = if all_sized { 0 } else { 1 } ;
10291039 for ( idx, field) in
@@ -1048,15 +1058,6 @@ fn check_type_defn<'tcx, F>(
10481058 ) ;
10491059 }
10501060
1051- // All field types must be well-formed.
1052- for field in & variant. fields {
1053- fcx. register_wf_obligation (
1054- field. ty . into ( ) ,
1055- field. span ,
1056- ObligationCauseCode :: WellFormed ( Some ( WellFormedLoc :: Ty ( field. def_id ) ) ) ,
1057- )
1058- }
1059-
10601061 // Explicit `enum` discriminant values must const-evaluate successfully.
10611062 if let Some ( discr_def_id) = variant. explicit_discr {
10621063 let discr_substs = InternalSubsts :: identity_for_item ( tcx, discr_def_id. to_def_id ( ) ) ;
0 commit comments