@@ -231,6 +231,7 @@ impl fmt::Display for ValidityRequirement {
231231pub enum LayoutError < ' tcx > {
232232 Unknown ( Ty < ' tcx > ) ,
233233 SizeOverflow ( Ty < ' tcx > ) ,
234+ UnexpectedUnsized ( Ty < ' tcx > ) ,
234235 NormalizationFailure ( Ty < ' tcx > , NormalizationError < ' tcx > ) ,
235236 ReferencesError ( ErrorGuaranteed ) ,
236237 Cycle ( ErrorGuaranteed ) ,
@@ -244,6 +245,7 @@ impl<'tcx> LayoutError<'tcx> {
244245 match self {
245246 Unknown ( _) => middle_unknown_layout,
246247 SizeOverflow ( _) => middle_values_too_big,
248+ UnexpectedUnsized ( _) => middle_unexpected_unsized,
247249 NormalizationFailure ( _, _) => middle_cannot_be_normalized,
248250 Cycle ( _) => middle_cycle,
249251 ReferencesError ( _) => middle_layout_references_error,
@@ -257,6 +259,7 @@ impl<'tcx> LayoutError<'tcx> {
257259 match self {
258260 Unknown ( ty) => E :: Unknown { ty } ,
259261 SizeOverflow ( ty) => E :: Overflow { ty } ,
262+ UnexpectedUnsized ( ty) => E :: Unsized { ty } ,
260263 NormalizationFailure ( ty, e) => {
261264 E :: NormalizationFailure { ty, failure_ty : e. get_type_for_failure ( ) }
262265 }
@@ -272,6 +275,9 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
272275 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
273276 match * self {
274277 LayoutError :: Unknown ( ty) => write ! ( f, "the type `{ty}` has an unknown layout" ) ,
278+ LayoutError :: UnexpectedUnsized ( ty) => {
279+ write ! ( f, "cannot determine the layout for the type `{ty}`" )
280+ }
275281 LayoutError :: SizeOverflow ( ty) => {
276282 write ! ( f, "values of the type `{ty}` are too big for the target architecture" )
277283 }
@@ -355,6 +361,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
355361 Err (
356362 e @ LayoutError :: Cycle ( _)
357363 | e @ LayoutError :: SizeOverflow ( _)
364+ | e @ LayoutError :: UnexpectedUnsized ( _)
358365 | e @ LayoutError :: NormalizationFailure ( ..)
359366 | e @ LayoutError :: ReferencesError ( _) ,
360367 ) => return Err ( e) ,
0 commit comments