@@ -229,6 +229,9 @@ pub enum LayoutError<'tcx> {
229229 Unknown ( Ty < ' tcx > ) ,
230230 /// The size of a type exceeds [`TargetDataLayout::obj_size_bound`].
231231 SizeOverflow ( Ty < ' tcx > ) ,
232+ /// The size of a SIMD type exceeds either the max SIMD size, or the limit
233+ /// configured by #[rustc_simd_monomorphize_lane_limit].
234+ OversizedSimd ( Ty < ' tcx > , u64 ) ,
232235 /// The layout can vary due to a generic parameter.
233236 ///
234237 /// Unlike `Unknown`, this variant is a "soft" error and indicates that the layout
@@ -256,6 +259,7 @@ impl<'tcx> LayoutError<'tcx> {
256259 match self {
257260 Unknown ( _) => middle_layout_unknown,
258261 SizeOverflow ( _) => middle_layout_size_overflow,
262+ OversizedSimd ( _, _) => middle_layout_oversized_simd,
259263 TooGeneric ( _) => middle_layout_too_generic,
260264 NormalizationFailure ( _, _) => middle_layout_normalization_failure,
261265 Cycle ( _) => middle_layout_cycle,
@@ -270,6 +274,7 @@ impl<'tcx> LayoutError<'tcx> {
270274 match self {
271275 Unknown ( ty) => E :: Unknown { ty } ,
272276 SizeOverflow ( ty) => E :: Overflow { ty } ,
277+ OversizedSimd ( ty, max_lanes) => E :: OversizedSimd { ty, max_lanes } ,
273278 TooGeneric ( ty) => E :: TooGeneric { ty } ,
274279 NormalizationFailure ( ty, e) => {
275280 E :: NormalizationFailure { ty, failure_ty : e. get_type_for_failure ( ) }
@@ -292,6 +297,9 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
292297 LayoutError :: SizeOverflow ( ty) => {
293298 write ! ( f, "values of the type `{ty}` are too big for the target architecture" )
294299 }
300+ LayoutError :: OversizedSimd ( ty, max_lanes) => {
301+ write ! ( f, "the SIMD type `{ty}` has more elements than the limit {max_lanes}" )
302+ }
295303 LayoutError :: NormalizationFailure ( t, e) => write ! (
296304 f,
297305 "unable to determine layout for `{}` because `{}` cannot be normalized" ,
@@ -373,6 +381,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
373381 e @ LayoutError :: Cycle ( _)
374382 | e @ LayoutError :: Unknown ( _)
375383 | e @ LayoutError :: SizeOverflow ( _)
384+ | e @ LayoutError :: OversizedSimd ( _, _)
376385 | e @ LayoutError :: NormalizationFailure ( ..)
377386 | e @ LayoutError :: ReferencesError ( _) ,
378387 ) => return Err ( e) ,
0 commit comments