@@ -72,18 +72,15 @@ pub type Variants = hir_def::layout::Variants<RustcFieldIdx, RustcEnumVariantIdx
7272
7373#[ derive( Debug , PartialEq , Eq , Clone ) ]
7474pub enum LayoutError {
75- // FIXME: Remove variants that duplicate LayoutCalculatorError's variants after sync
75+ // FIXME: Remove more variants once they get added to LayoutCalculatorError
7676BadCalc ( LayoutCalculatorError < ( ) > ) ,
77- EmptyUnion ,
7877HasErrorConst ,
7978HasErrorType ,
8079HasPlaceholder ,
8180InvalidSimdType ,
8281NotImplemented ,
8382RecursiveTypeWithoutIndirection ,
84- SizeOverflow ,
8583TargetLayoutNotAvailable ,
86- UnexpectedUnsized ,
8784Unknown ,
8885UserReprTooSmall ,
8986}
@@ -93,7 +90,6 @@ impl fmt::Display for LayoutError {
9390fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
9491match self {
9592LayoutError :: BadCalc ( err) => err. fallback_fmt ( f) ,
96- LayoutError :: EmptyUnion => write ! ( f, "type is an union with no fields" ) ,
9793LayoutError :: HasErrorConst => write ! ( f, "type contains an unevaluatable const" ) ,
9894LayoutError :: HasErrorType => write ! ( f, "type contains an error" ) ,
9995LayoutError :: HasPlaceholder => write ! ( f, "type contains placeholders" ) ,
@@ -102,11 +98,7 @@ impl fmt::Display for LayoutError {
10298LayoutError :: RecursiveTypeWithoutIndirection => {
10399write ! ( f, "recursive type without indirection" )
104100}
105- LayoutError :: SizeOverflow => write ! ( f, "size overflow" ) ,
106101LayoutError :: TargetLayoutNotAvailable => write ! ( f, "target layout not available" ) ,
107- LayoutError :: UnexpectedUnsized => {
108- write ! ( f, "an unsized type was found where a sized type was expected" )
109- }
110102LayoutError :: Unknown => write ! ( f, "unknown" ) ,
111103LayoutError :: UserReprTooSmall => {
112104write ! ( f, "the `#[repr]` hint is too small to hold the discriminants of the enum" )
@@ -181,7 +173,10 @@ fn layout_of_simd_ty(
181173} ;
182174
183175// Compute the size and alignment of the vector:
184- let size = e_ly. size . checked_mul ( e_len, dl) . ok_or ( LayoutError :: SizeOverflow ) ?;
176+ let size = e_ly
177+ . size
178+ . checked_mul ( e_len, dl)
179+ . ok_or ( LayoutError :: BadCalc ( LayoutCalculatorError :: SizeOverflow ) ) ?;
185180let align = dl. vector_align ( size) ;
186181let size = size. align_to ( align. abi ) ;
187182
@@ -294,7 +289,10 @@ pub fn layout_of_ty_query(
294289TyKind :: Array ( element, count) => {
295290let count = try_const_usize ( db, count) . ok_or ( LayoutError :: HasErrorConst ) ? as u64 ;
296291let element = db. layout_of_ty ( element. clone ( ) , trait_env) ?;
297- let size = element. size . checked_mul ( count, dl) . ok_or ( LayoutError :: SizeOverflow ) ?;
292+ let size = element
293+ . size
294+ . checked_mul ( count, dl)
295+ . ok_or ( LayoutError :: BadCalc ( LayoutCalculatorError :: SizeOverflow ) ) ?;
298296
299297let abi = if count != 0 && matches ! ( element. abi, Abi :: Uninhabited ) {
300298Abi :: Uninhabited
0 commit comments