@@ -72,18 +72,15 @@ pub type Variants = hir_def::layout::Variants<RustcFieldIdx, RustcEnumVariantIdx
72
72
73
73
#[ derive( Debug , PartialEq , Eq , Clone ) ]
74
74
pub enum LayoutError {
75
- // FIXME: Remove variants that duplicate LayoutCalculatorError's variants after sync
75
+ // FIXME: Remove more variants once they get added to LayoutCalculatorError
76
76
BadCalc ( LayoutCalculatorError < ( ) > ) ,
77
- EmptyUnion ,
78
77
HasErrorConst ,
79
78
HasErrorType ,
80
79
HasPlaceholder ,
81
80
InvalidSimdType ,
82
81
NotImplemented ,
83
82
RecursiveTypeWithoutIndirection ,
84
- SizeOverflow ,
85
83
TargetLayoutNotAvailable ,
86
- UnexpectedUnsized ,
87
84
Unknown ,
88
85
UserReprTooSmall ,
89
86
}
@@ -93,7 +90,6 @@ impl fmt::Display for LayoutError {
93
90
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
94
91
match self {
95
92
LayoutError :: BadCalc ( err) => err. fallback_fmt ( f) ,
96
- LayoutError :: EmptyUnion => write ! ( f, "type is an union with no fields" ) ,
97
93
LayoutError :: HasErrorConst => write ! ( f, "type contains an unevaluatable const" ) ,
98
94
LayoutError :: HasErrorType => write ! ( f, "type contains an error" ) ,
99
95
LayoutError :: HasPlaceholder => write ! ( f, "type contains placeholders" ) ,
@@ -102,11 +98,7 @@ impl fmt::Display for LayoutError {
102
98
LayoutError :: RecursiveTypeWithoutIndirection => {
103
99
write ! ( f, "recursive type without indirection" )
104
100
}
105
- LayoutError :: SizeOverflow => write ! ( f, "size overflow" ) ,
106
101
LayoutError :: 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
- }
110
102
LayoutError :: Unknown => write ! ( f, "unknown" ) ,
111
103
LayoutError :: UserReprTooSmall => {
112
104
write ! ( f, "the `#[repr]` hint is too small to hold the discriminants of the enum" )
@@ -181,7 +173,10 @@ fn layout_of_simd_ty(
181
173
} ;
182
174
183
175
// 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 ) ) ?;
185
180
let align = dl. vector_align ( size) ;
186
181
let size = size. align_to ( align. abi ) ;
187
182
@@ -294,7 +289,10 @@ pub fn layout_of_ty_query(
294
289
TyKind :: Array ( element, count) => {
295
290
let count = try_const_usize ( db, count) . ok_or ( LayoutError :: HasErrorConst ) ? as u64 ;
296
291
let 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 ) ) ?;
298
296
299
297
let abi = if count != 0 && matches ! ( element. abi, Abi :: Uninhabited ) {
300
298
Abi :: Uninhabited
0 commit comments