Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #18364 - lnicola:sync-from-rust, r=lnicola
minor: sync from downstream
bors 2024-10-22
parent de2ff17 · parent a320392 · commit 7338788
-rw-r--r--Cargo.lock26
-rw-r--r--Cargo.toml10
-rw-r--r--crates/hir-ty/src/layout.rs27
-rw-r--r--rust-version2
4 files changed, 31 insertions, 34 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 951c7f8bba..fd569571b3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1497,9 +1497,9 @@ dependencies = [
[[package]]
name = "ra-ap-rustc_abi"
-version = "0.71.0"
+version = "0.73.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c6999d098000b98415939f13158dac78cb3eeeb7b0c073847f3e4b623866e27c"
+checksum = "879ece0781e3c1cb670b9f29775c81a43a16db789d1296fad6bc5c74065b2fac"
dependencies = [
"bitflags 2.6.0",
"ra-ap-rustc_index",
@@ -1508,9 +1508,9 @@ dependencies = [
[[package]]
name = "ra-ap-rustc_index"
-version = "0.71.0"
+version = "0.73.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ae9fb312d942817dab10790881f555928c1f6a11a85186e8e573ad4a86c7d3be"
+checksum = "6910087ff89bb9f3db114bfcd86b5139042731fe7278d3ff4ceaa69a140154a7"
dependencies = [
"arrayvec",
"ra-ap-rustc_index_macros",
@@ -1519,9 +1519,9 @@ dependencies = [
[[package]]
name = "ra-ap-rustc_index_macros"
-version = "0.71.0"
+version = "0.73.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "766e3990eb1066a06deefc561b5a01b32ca5c9211feea31cbf4ed50611519872"
+checksum = "3b6f7bd12b678fbb37444ba77f3b0cfc13b7394a6dc7b0c799491fc9df0a9997"
dependencies = [
"proc-macro2",
"quote",
@@ -1530,9 +1530,9 @@ dependencies = [
[[package]]
name = "ra-ap-rustc_lexer"
-version = "0.71.0"
+version = "0.73.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f4afa98eb7889c137d5a3f1cd189089e16da04d1e4837d358a67aa3dab10ffbe"
+checksum = "119bc05b5b6bc3e7f5b67ce8b8080e185da94bd83c447f91b6b3f3ecf60cbab1"
dependencies = [
"unicode-properties",
"unicode-xid",
@@ -1540,9 +1540,9 @@ dependencies = [
[[package]]
name = "ra-ap-rustc_parse_format"
-version = "0.71.0"
+version = "0.73.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9234c96ffb0565286790407fb7eb7f55ebf69267de4db382fdec0a17f14b0e2"
+checksum = "70ed6150ae71d905c064dc88d7824ebb0fa81083f45d7477cba7b57176f2f635"
dependencies = [
"ra-ap-rustc_index",
"ra-ap-rustc_lexer",
@@ -1550,12 +1550,12 @@ dependencies = [
[[package]]
name = "ra-ap-rustc_pattern_analysis"
-version = "0.71.0"
+version = "0.73.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "273d5f72926a58c7eea27aebc898d1d5b32d23d2342f692a94a2cf8746aa4a2f"
+checksum = "6e830862a0ec85fce211d34735315686bb8d6a12d418d6d735fb534aa1cd3293"
dependencies = [
"ra-ap-rustc_index",
- "rustc-hash 1.1.0",
+ "rustc-hash 2.0.0",
"rustc_apfloat",
"smallvec",
"tracing",
diff --git a/Cargo.toml b/Cargo.toml
index 397c68319d..9db62de9ab 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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" }
diff --git a/crates/hir-ty/src/layout.rs b/crates/hir-ty/src/layout.rs
index bfbae2941d..8083144072 100644
--- a/crates/hir-ty/src/layout.rs
+++ b/crates/hir-ty/src/layout.rs
@@ -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,
}
@@ -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"),
@@ -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")
@@ -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())
}
}
@@ -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);
@@ -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
diff --git a/rust-version b/rust-version
index d0f9fa7ac4..bc324402a9 100644
--- a/rust-version
+++ b/rust-version
@@ -1 +1 @@
-dd5127615ad626741a1116d022cf784637ac05df
+1de57a5ce952c722f7053aeacfc6c90bc139b678