Skip to content

Commit

Permalink
Auto merge of #18364 - lnicola:sync-from-rust, r=lnicola
Browse files Browse the repository at this point in the history
minor: sync from downstream
  • Loading branch information
bors committed Oct 22, 2024
2 parents de2ff17 + a320392 commit 7338788
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 34 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ tt = { path = "./crates/tt", version = "0.0.0" }
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
vfs = { path = "./crates/vfs", version = "0.0.0" }

ra-ap-rustc_lexer = { version = "0.71.0", default-features = false }
ra-ap-rustc_parse_format = { version = "0.71.0", default-features = false }
ra-ap-rustc_index = { version = "0.71.0", default-features = false }
ra-ap-rustc_abi = { version = "0.71.0", default-features = false }
ra-ap-rustc_pattern_analysis = { version = "0.71.0", default-features = false }
ra-ap-rustc_lexer = { version = "0.73", default-features = false }
ra-ap-rustc_parse_format = { version = "0.73", default-features = false }
ra-ap-rustc_index = { version = "0.73", default-features = false }
ra-ap-rustc_abi = { version = "0.73", default-features = false }
ra-ap-rustc_pattern_analysis = { version = "0.73", default-features = false }

# local crates that aren't published to crates.io. These should not have versions.
test-fixture = { path = "./crates/test-fixture" }
Expand Down
27 changes: 12 additions & 15 deletions crates/hir-ty/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,15 @@ pub type Variants = hir_def::layout::Variants<RustcFieldIdx, RustcEnumVariantIdx

#[derive(Debug, PartialEq, Eq, Clone)]
pub enum LayoutError {
EmptyUnion,
// FIXME: Remove more variants once they get added to LayoutCalculatorError
BadCalc(LayoutCalculatorError<()>),
HasErrorConst,
HasErrorType,
HasPlaceholder,
InvalidSimdType,
NotImplemented,
RecursiveTypeWithoutIndirection,
SizeOverflow,
TargetLayoutNotAvailable,
UnexpectedUnsized,
Unknown,
UserReprTooSmall,
}
Expand All @@ -90,7 +89,7 @@ impl std::error::Error for LayoutError {}
impl fmt::Display for LayoutError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
LayoutError::EmptyUnion => write!(f, "type is an union with no fields"),
LayoutError::BadCalc(err) => err.fallback_fmt(f),
LayoutError::HasErrorConst => write!(f, "type contains an unevaluatable const"),
LayoutError::HasErrorType => write!(f, "type contains an error"),
LayoutError::HasPlaceholder => write!(f, "type contains placeholders"),
Expand All @@ -99,11 +98,7 @@ impl fmt::Display for LayoutError {
LayoutError::RecursiveTypeWithoutIndirection => {
write!(f, "recursive type without indirection")
}
LayoutError::SizeOverflow => write!(f, "size overflow"),
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::UserReprTooSmall => {
write!(f, "the `#[repr]` hint is too small to hold the discriminants of the enum")
Expand All @@ -114,11 +109,7 @@ impl fmt::Display for LayoutError {

impl<F> From<LayoutCalculatorError<F>> for LayoutError {
fn from(err: LayoutCalculatorError<F>) -> Self {
match err {
LayoutCalculatorError::EmptyUnion => LayoutError::EmptyUnion,
LayoutCalculatorError::UnexpectedUnsized(_) => LayoutError::UnexpectedUnsized,
LayoutCalculatorError::SizeOverflow => LayoutError::SizeOverflow,
}
LayoutError::BadCalc(err.without_payload())
}
}

Expand Down Expand Up @@ -182,7 +173,10 @@ fn layout_of_simd_ty(
};

// Compute the size and alignment of the vector:
let size = e_ly.size.checked_mul(e_len, dl).ok_or(LayoutError::SizeOverflow)?;
let size = e_ly
.size
.checked_mul(e_len, dl)
.ok_or(LayoutError::BadCalc(LayoutCalculatorError::SizeOverflow))?;
let align = dl.vector_align(size);
let size = size.align_to(align.abi);

Expand Down Expand Up @@ -295,7 +289,10 @@ pub fn layout_of_ty_query(
TyKind::Array(element, count) => {
let count = try_const_usize(db, count).ok_or(LayoutError::HasErrorConst)? as u64;
let element = db.layout_of_ty(element.clone(), trait_env)?;
let size = element.size.checked_mul(count, dl).ok_or(LayoutError::SizeOverflow)?;
let size = element
.size
.checked_mul(count, dl)
.ok_or(LayoutError::BadCalc(LayoutCalculatorError::SizeOverflow))?;

let abi = if count != 0 && matches!(element.abi, Abi::Uninhabited) {
Abi::Uninhabited
Expand Down
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dd5127615ad626741a1116d022cf784637ac05df
1de57a5ce952c722f7053aeacfc6c90bc139b678

0 comments on commit 7338788

Please sign in to comment.