@@ -1102,25 +1102,28 @@ impl<'tcx> Ty<'tcx> {
11021102 let variant = def. non_enum_variant ( ) ;
11031103 let f0_ty = variant. fields [ FieldIdx :: ZERO ] . ty ( tcx, args) ;
11041104
1105- match f0_ty. kind ( ) {
1106- Array ( _, _) if def. repr ( ) . scalable ( ) => {
1107- bug ! ( "Scalable SIMD should be using a slice, not array" ) ;
1105+ if def. repr ( ) . scalable ( ) {
1106+ match f0_ty. kind ( ) {
1107+ Slice ( f0_elem_ty) => ( def. repr ( ) . scalable . unwrap_or ( 0 ) as u64 , * f0_elem_ty) ,
1108+ _ => {
1109+ bug ! ( "Scalable SIMD should be using a slice" ) ;
1110+ }
11081111 }
1109- Slice ( f0_elem_ty) if def. repr ( ) . scalable ( ) => {
1110- ( def. repr ( ) . scalable . unwrap_or ( 0 ) as u64 , * f0_elem_ty)
1111- }
1112- // If the first field is an array, we assume it is the only field and its
1113- // elements are the SIMD components.
1114- Array ( f0_elem_ty, f0_len) => {
1115- // FIXME(repr_simd): https://github.com/rust-lang/rust/pull/78863#discussion_r522784112
1116- // The way we evaluate the `N` in `[T; N]` here only works since we use
1117- // `simd_size_and_type` post-monomorphization. It will probably start to ICE
1118- // if we use it in generic code. See the `simd-array-trait` ui test.
1119- ( f0_len. eval_target_usize ( tcx, ParamEnv :: empty ( ) ) , * f0_elem_ty)
1112+ } else {
1113+ match f0_ty. kind ( ) {
1114+ // If the first field is an array, we assume it is the only field and its
1115+ // elements are the SIMD components.
1116+ Array ( f0_elem_ty, f0_len) => {
1117+ // FIXME(repr_simd): https://github.com/rust-lang/rust/pull/78863#discussion_r522784112
1118+ // The way we evaluate the `N` in `[T; N]` here only works since we use
1119+ // `simd_size_and_type` post-monomorphization. It will probably start to ICE
1120+ // if we use it in generic code. See the `simd-array-trait` ui test.
1121+ ( f0_len. eval_target_usize ( tcx, ParamEnv :: empty ( ) ) , * f0_elem_ty)
1122+ }
1123+ // Otherwise, the fields of this Adt are the SIMD components (and we assume they
1124+ // all have the same type).
1125+ _ => ( variant. fields . len ( ) as u64 , f0_ty) ,
11201126 }
1121- // Otherwise, the fields of this Adt are the SIMD components (and we assume they
1122- // all have the same type).
1123- _ => ( variant. fields . len ( ) as u64 , f0_ty) ,
11241127 }
11251128 }
11261129 _ => bug ! ( "`simd_size_and_type` called on invalid type" ) ,
0 commit comments