@@ -1008,6 +1008,15 @@ fn check_type_defn<'tcx, F>(
1008
1008
let packed = tcx. adt_def ( item. def_id ) . repr ( ) . packed ( ) ;
1009
1009
1010
1010
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
+
1011
1020
// For DST, or when drop needs to copy things around, all
1012
1021
// intermediate types must be sized.
1013
1022
let needs_drop_copy = || {
@@ -1024,6 +1033,7 @@ fn check_type_defn<'tcx, F>(
1024
1033
}
1025
1034
}
1026
1035
} ;
1036
+ // All fields (except for possibly the last) should be sized.
1027
1037
let all_sized = all_sized || variant. fields . is_empty ( ) || needs_drop_copy ( ) ;
1028
1038
let unsized_len = if all_sized { 0 } else { 1 } ;
1029
1039
for ( idx, field) in
@@ -1048,15 +1058,6 @@ fn check_type_defn<'tcx, F>(
1048
1058
) ;
1049
1059
}
1050
1060
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
-
1060
1061
// Explicit `enum` discriminant values must const-evaluate successfully.
1061
1062
if let Some ( discr_def_id) = variant. explicit_discr {
1062
1063
let discr_substs = InternalSubsts :: identity_for_item ( tcx, discr_def_id. to_def_id ( ) ) ;
0 commit comments