@@ -72,6 +72,7 @@ pub type Variants = hir_def::layout::Variants<RustcFieldIdx, RustcEnumVariantIdx
7272
7373#[ derive( Debug , PartialEq , Eq , Clone ) ]
7474pub enum LayoutError {
75+ EmptyUnion ,
7576 HasErrorConst ,
7677 HasErrorType ,
7778 HasPlaceholder ,
@@ -80,6 +81,7 @@ pub enum LayoutError {
8081 RecursiveTypeWithoutIndirection ,
8182 SizeOverflow ,
8283 TargetLayoutNotAvailable ,
84+ UnexpectedUnsized ,
8385 Unknown ,
8486 UserReprTooSmall ,
8587}
@@ -88,6 +90,7 @@ impl std::error::Error for LayoutError {}
8890impl fmt:: Display for LayoutError {
8991 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
9092 match self {
93+ LayoutError :: EmptyUnion => write ! ( f, "type is an union with no fields" ) ,
9194 LayoutError :: HasErrorConst => write ! ( f, "type contains an unevaluatable const" ) ,
9295 LayoutError :: HasErrorType => write ! ( f, "type contains an error" ) ,
9396 LayoutError :: HasPlaceholder => write ! ( f, "type contains placeholders" ) ,
@@ -98,6 +101,9 @@ impl fmt::Display for LayoutError {
98101 }
99102 LayoutError :: SizeOverflow => write ! ( f, "size overflow" ) ,
100103 LayoutError :: TargetLayoutNotAvailable => write ! ( f, "target layout not available" ) ,
104+ LayoutError :: UnexpectedUnsized => {
105+ write ! ( f, "an unsized type was found where a sized type was expected" )
106+ }
101107 LayoutError :: Unknown => write ! ( f, "unknown" ) ,
102108 LayoutError :: UserReprTooSmall => {
103109 write ! ( f, "the `#[repr]` hint is too small to hold the discriminants of the enum" )
@@ -109,9 +115,8 @@ impl fmt::Display for LayoutError {
109115impl < F > From < LayoutCalculatorError < F > > for LayoutError {
110116 fn from ( err : LayoutCalculatorError < F > ) -> Self {
111117 match err {
112- LayoutCalculatorError :: UnexpectedUnsized ( _) | LayoutCalculatorError :: EmptyUnion => {
113- LayoutError :: Unknown
114- }
118+ LayoutCalculatorError :: EmptyUnion => LayoutError :: EmptyUnion ,
119+ LayoutCalculatorError :: UnexpectedUnsized ( _) => LayoutError :: UnexpectedUnsized ,
115120 LayoutCalculatorError :: SizeOverflow => LayoutError :: SizeOverflow ,
116121 }
117122 }
0 commit comments