mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
Add more LayoutError variants
This commit is contained in:
parent
62aac8dd4f
commit
329eef0018
@ -72,6 +72,7 @@ pub type Variants = hir_def::layout::Variants<RustcFieldIdx, RustcEnumVariantIdx
|
|||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
pub enum LayoutError {
|
pub enum LayoutError {
|
||||||
|
EmptyUnion,
|
||||||
HasErrorConst,
|
HasErrorConst,
|
||||||
HasErrorType,
|
HasErrorType,
|
||||||
HasPlaceholder,
|
HasPlaceholder,
|
||||||
@ -80,6 +81,7 @@ pub enum LayoutError {
|
|||||||
RecursiveTypeWithoutIndirection,
|
RecursiveTypeWithoutIndirection,
|
||||||
SizeOverflow,
|
SizeOverflow,
|
||||||
TargetLayoutNotAvailable,
|
TargetLayoutNotAvailable,
|
||||||
|
UnexpectedUnsized,
|
||||||
Unknown,
|
Unknown,
|
||||||
UserReprTooSmall,
|
UserReprTooSmall,
|
||||||
}
|
}
|
||||||
@ -88,6 +90,7 @@ impl std::error::Error for LayoutError {}
|
|||||||
impl fmt::Display for LayoutError {
|
impl fmt::Display for LayoutError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
LayoutError::EmptyUnion => write!(f, "type is an union with no fields"),
|
||||||
LayoutError::HasErrorConst => write!(f, "type contains an unevaluatable const"),
|
LayoutError::HasErrorConst => write!(f, "type contains an unevaluatable const"),
|
||||||
LayoutError::HasErrorType => write!(f, "type contains an error"),
|
LayoutError::HasErrorType => write!(f, "type contains an error"),
|
||||||
LayoutError::HasPlaceholder => write!(f, "type contains placeholders"),
|
LayoutError::HasPlaceholder => write!(f, "type contains placeholders"),
|
||||||
@ -98,6 +101,9 @@ impl fmt::Display for LayoutError {
|
|||||||
}
|
}
|
||||||
LayoutError::SizeOverflow => write!(f, "size overflow"),
|
LayoutError::SizeOverflow => write!(f, "size overflow"),
|
||||||
LayoutError::TargetLayoutNotAvailable => write!(f, "target layout not available"),
|
LayoutError::TargetLayoutNotAvailable => write!(f, "target layout not available"),
|
||||||
|
LayoutError::UnexpectedUnsized => {
|
||||||
|
write!(f, "an unsized type was found where a sized type was expected")
|
||||||
|
}
|
||||||
LayoutError::Unknown => write!(f, "unknown"),
|
LayoutError::Unknown => write!(f, "unknown"),
|
||||||
LayoutError::UserReprTooSmall => {
|
LayoutError::UserReprTooSmall => {
|
||||||
write!(f, "the `#[repr]` hint is too small to hold the discriminants of the enum")
|
write!(f, "the `#[repr]` hint is too small to hold the discriminants of the enum")
|
||||||
@ -109,9 +115,8 @@ impl fmt::Display for LayoutError {
|
|||||||
impl<F> From<LayoutCalculatorError<F>> for LayoutError {
|
impl<F> From<LayoutCalculatorError<F>> for LayoutError {
|
||||||
fn from(err: LayoutCalculatorError<F>) -> Self {
|
fn from(err: LayoutCalculatorError<F>) -> Self {
|
||||||
match err {
|
match err {
|
||||||
LayoutCalculatorError::UnexpectedUnsized(_) | LayoutCalculatorError::EmptyUnion => {
|
LayoutCalculatorError::EmptyUnion => LayoutError::EmptyUnion,
|
||||||
LayoutError::Unknown
|
LayoutCalculatorError::UnexpectedUnsized(_) => LayoutError::UnexpectedUnsized,
|
||||||
}
|
|
||||||
LayoutCalculatorError::SizeOverflow => LayoutError::SizeOverflow,
|
LayoutCalculatorError::SizeOverflow => LayoutError::SizeOverflow,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user