Skip to content

Commit a320392

Browse files
committed
Replace some LayoutError variants with the rustc_abi errors
1 parent 8d479d0 commit a320392

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/hir-ty/src/layout.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,15 @@ 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
75+
// FIXME: Remove more variants once they get added to LayoutCalculatorError
7676
BadCalc(LayoutCalculatorError<()>),
77-
EmptyUnion,
7877
HasErrorConst,
7978
HasErrorType,
8079
HasPlaceholder,
8180
InvalidSimdType,
8281
NotImplemented,
8382
RecursiveTypeWithoutIndirection,
84-
SizeOverflow,
8583
TargetLayoutNotAvailable,
86-
UnexpectedUnsized,
8784
Unknown,
8885
UserReprTooSmall,
8986
}
@@ -93,7 +90,6 @@ impl fmt::Display for LayoutError {
9390
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9491
match self {
9592
LayoutError::BadCalc(err) => err.fallback_fmt(f),
96-
LayoutError::EmptyUnion => write!(f, "type is an union with no fields"),
9793
LayoutError::HasErrorConst => write!(f, "type contains an unevaluatable const"),
9894
LayoutError::HasErrorType => write!(f, "type contains an error"),
9995
LayoutError::HasPlaceholder => write!(f, "type contains placeholders"),
@@ -102,11 +98,7 @@ impl fmt::Display for LayoutError {
10298
LayoutError::RecursiveTypeWithoutIndirection => {
10399
write!(f, "recursive type without indirection")
104100
}
105-
LayoutError::SizeOverflow => write!(f, "size overflow"),
106101
LayoutError::TargetLayoutNotAvailable => write!(f, "target layout not available"),
107-
LayoutError::UnexpectedUnsized => {
108-
write!(f, "an unsized type was found where a sized type was expected")
109-
}
110102
LayoutError::Unknown => write!(f, "unknown"),
111103
LayoutError::UserReprTooSmall => {
112104
write!(f, "the `#[repr]` hint is too small to hold the discriminants of the enum")
@@ -181,7 +173,10 @@ fn layout_of_simd_ty(
181173
};
182174

183175
// Compute the size and alignment of the vector:
184-
let size = e_ly.size.checked_mul(e_len, dl).ok_or(LayoutError::SizeOverflow)?;
176+
let size = e_ly
177+
.size
178+
.checked_mul(e_len, dl)
179+
.ok_or(LayoutError::BadCalc(LayoutCalculatorError::SizeOverflow))?;
185180
let align = dl.vector_align(size);
186181
let size = size.align_to(align.abi);
187182

@@ -294,7 +289,10 @@ pub fn layout_of_ty_query(
294289
TyKind::Array(element, count) => {
295290
let count = try_const_usize(db, count).ok_or(LayoutError::HasErrorConst)? as u64;
296291
let element = db.layout_of_ty(element.clone(), trait_env)?;
297-
let size = element.size.checked_mul(count, dl).ok_or(LayoutError::SizeOverflow)?;
292+
let size = element
293+
.size
294+
.checked_mul(count, dl)
295+
.ok_or(LayoutError::BadCalc(LayoutCalculatorError::SizeOverflow))?;
298296

299297
let abi = if count != 0 && matches!(element.abi, Abi::Uninhabited) {
300298
Abi::Uninhabited

0 commit comments

Comments
 (0)