@@ -72,6 +72,7 @@ pub type Variants = hir_def::layout::Variants<RustcFieldIdx, RustcEnumVariantIdx
72
72
73
73
#[ derive( Debug , PartialEq , Eq , Clone ) ]
74
74
pub enum LayoutError {
75
+ EmptyUnion ,
75
76
HasErrorConst ,
76
77
HasErrorType ,
77
78
HasPlaceholder ,
@@ -80,6 +81,7 @@ pub enum LayoutError {
80
81
RecursiveTypeWithoutIndirection ,
81
82
SizeOverflow ,
82
83
TargetLayoutNotAvailable ,
84
+ UnexpectedUnsized ,
83
85
Unknown ,
84
86
UserReprTooSmall ,
85
87
}
@@ -88,6 +90,7 @@ impl std::error::Error for LayoutError {}
88
90
impl fmt:: Display for LayoutError {
89
91
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
90
92
match self {
93
+ LayoutError :: EmptyUnion => write ! ( f, "type is an union with no fields" ) ,
91
94
LayoutError :: HasErrorConst => write ! ( f, "type contains an unevaluatable const" ) ,
92
95
LayoutError :: HasErrorType => write ! ( f, "type contains an error" ) ,
93
96
LayoutError :: HasPlaceholder => write ! ( f, "type contains placeholders" ) ,
@@ -98,6 +101,9 @@ impl fmt::Display for LayoutError {
98
101
}
99
102
LayoutError :: SizeOverflow => write ! ( f, "size overflow" ) ,
100
103
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
+ }
101
107
LayoutError :: Unknown => write ! ( f, "unknown" ) ,
102
108
LayoutError :: UserReprTooSmall => {
103
109
write ! ( f, "the `#[repr]` hint is too small to hold the discriminants of the enum" )
@@ -109,9 +115,8 @@ impl fmt::Display for LayoutError {
109
115
impl < F > From < LayoutCalculatorError < F > > for LayoutError {
110
116
fn from ( err : LayoutCalculatorError < F > ) -> Self {
111
117
match err {
112
- LayoutCalculatorError :: UnexpectedUnsized ( _) | LayoutCalculatorError :: EmptyUnion => {
113
- LayoutError :: Unknown
114
- }
118
+ LayoutCalculatorError :: EmptyUnion => LayoutError :: EmptyUnion ,
119
+ LayoutCalculatorError :: UnexpectedUnsized ( _) => LayoutError :: UnexpectedUnsized ,
115
120
LayoutCalculatorError :: SizeOverflow => LayoutError :: SizeOverflow ,
116
121
}
117
122
}
0 commit comments