Skip to content

Commit a3cd353

Browse files
rust-analyzer: Nest LayoutCalculatorError in hir_ty::LayoutError
1 parent edc0508 commit a3cd353

File tree

1 file changed

+4
-5
lines changed
  • src/tools/rust-analyzer/crates/hir-ty/src

1 file changed

+4
-5
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/layout.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ pub type Variants = hir_def::layout::Variants<RustcFieldIdx, RustcEnumVariantIdx
7272

7373
#[derive(Debug, PartialEq, Eq, Clone)]
7474
pub enum LayoutError {
75+
// FIXME: Remove variants that duplicate LayoutCalculatorError's variants after sync
76+
BadCalc(layout::LayoutCalculatorError<()>),
7577
EmptyUnion,
7678
HasErrorConst,
7779
HasErrorType,
@@ -90,6 +92,7 @@ impl std::error::Error for LayoutError {}
9092
impl fmt::Display for LayoutError {
9193
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9294
match self {
95+
LayoutError::BadCalc(err) => write!(f, "{}", err.fallback_fmt()),
9396
LayoutError::EmptyUnion => write!(f, "type is an union with no fields"),
9497
LayoutError::HasErrorConst => write!(f, "type contains an unevaluatable const"),
9598
LayoutError::HasErrorType => write!(f, "type contains an error"),
@@ -114,11 +117,7 @@ impl fmt::Display for LayoutError {
114117

115118
impl<F> From<LayoutCalculatorError<F>> for LayoutError {
116119
fn from(err: LayoutCalculatorError<F>) -> Self {
117-
match err {
118-
LayoutCalculatorError::EmptyUnion => LayoutError::EmptyUnion,
119-
LayoutCalculatorError::UnexpectedUnsized(_) => LayoutError::UnexpectedUnsized,
120-
LayoutCalculatorError::SizeOverflow => LayoutError::SizeOverflow,
121-
}
120+
LayoutError::BadCalc(err.without_payload())
122121
}
123122
}
124123

0 commit comments

Comments
 (0)