mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
rust-analyzer: Nest LayoutCalculatorError
in hir_ty::LayoutError
This commit is contained in:
parent
848af21981
commit
90ec8053c2
1 changed files with 4 additions and 5 deletions
|
@ -72,6 +72,8 @@ 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 {
|
||||||
|
// FIXME: Remove variants that duplicate LayoutCalculatorError's variants after sync
|
||||||
|
BadCalc(LayoutCalculatorError<()>),
|
||||||
EmptyUnion,
|
EmptyUnion,
|
||||||
HasErrorConst,
|
HasErrorConst,
|
||||||
HasErrorType,
|
HasErrorType,
|
||||||
|
@ -90,6 +92,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::BadCalc(err) => err.fallback_fmt(f),
|
||||||
LayoutError::EmptyUnion => write!(f, "type is an union with no fields"),
|
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"),
|
||||||
|
@ -114,11 +117,7 @@ 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 {
|
LayoutError::BadCalc(err.without_payload())
|
||||||
LayoutCalculatorError::EmptyUnion => LayoutError::EmptyUnion,
|
|
||||||
LayoutCalculatorError::UnexpectedUnsized(_) => LayoutError::UnexpectedUnsized,
|
|
||||||
LayoutCalculatorError::SizeOverflow => LayoutError::SizeOverflow,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue