Skip to content

Commit efc2ba2

Browse files
committed
Replace some LayoutError variants with the rustc_abi errors
1 parent 420b665 commit efc2ba2

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

src/tools/rust-analyzer/Cargo.lock

+13-13
Original file line numberDiff line numberDiff line change
@@ -1497,9 +1497,9 @@ dependencies = [
14971497

14981498
[[package]]
14991499
name = "ra-ap-rustc_abi"
1500-
version = "0.71.0"
1500+
version = "0.73.0"
15011501
source = "registry+https://github.com/rust-lang/crates.io-index"
1502-
checksum = "c6999d098000b98415939f13158dac78cb3eeeb7b0c073847f3e4b623866e27c"
1502+
checksum = "879ece0781e3c1cb670b9f29775c81a43a16db789d1296fad6bc5c74065b2fac"
15031503
dependencies = [
15041504
"bitflags 2.6.0",
15051505
"ra-ap-rustc_index",
@@ -1508,9 +1508,9 @@ dependencies = [
15081508

15091509
[[package]]
15101510
name = "ra-ap-rustc_index"
1511-
version = "0.71.0"
1511+
version = "0.73.0"
15121512
source = "registry+https://github.com/rust-lang/crates.io-index"
1513-
checksum = "ae9fb312d942817dab10790881f555928c1f6a11a85186e8e573ad4a86c7d3be"
1513+
checksum = "6910087ff89bb9f3db114bfcd86b5139042731fe7278d3ff4ceaa69a140154a7"
15141514
dependencies = [
15151515
"arrayvec",
15161516
"ra-ap-rustc_index_macros",
@@ -1519,9 +1519,9 @@ dependencies = [
15191519

15201520
[[package]]
15211521
name = "ra-ap-rustc_index_macros"
1522-
version = "0.71.0"
1522+
version = "0.73.0"
15231523
source = "registry+https://github.com/rust-lang/crates.io-index"
1524-
checksum = "766e3990eb1066a06deefc561b5a01b32ca5c9211feea31cbf4ed50611519872"
1524+
checksum = "3b6f7bd12b678fbb37444ba77f3b0cfc13b7394a6dc7b0c799491fc9df0a9997"
15251525
dependencies = [
15261526
"proc-macro2",
15271527
"quote",
@@ -1530,32 +1530,32 @@ dependencies = [
15301530

15311531
[[package]]
15321532
name = "ra-ap-rustc_lexer"
1533-
version = "0.71.0"
1533+
version = "0.73.0"
15341534
source = "registry+https://github.com/rust-lang/crates.io-index"
1535-
checksum = "f4afa98eb7889c137d5a3f1cd189089e16da04d1e4837d358a67aa3dab10ffbe"
1535+
checksum = "119bc05b5b6bc3e7f5b67ce8b8080e185da94bd83c447f91b6b3f3ecf60cbab1"
15361536
dependencies = [
15371537
"unicode-properties",
15381538
"unicode-xid",
15391539
]
15401540

15411541
[[package]]
15421542
name = "ra-ap-rustc_parse_format"
1543-
version = "0.71.0"
1543+
version = "0.73.0"
15441544
source = "registry+https://github.com/rust-lang/crates.io-index"
1545-
checksum = "d9234c96ffb0565286790407fb7eb7f55ebf69267de4db382fdec0a17f14b0e2"
1545+
checksum = "70ed6150ae71d905c064dc88d7824ebb0fa81083f45d7477cba7b57176f2f635"
15461546
dependencies = [
15471547
"ra-ap-rustc_index",
15481548
"ra-ap-rustc_lexer",
15491549
]
15501550

15511551
[[package]]
15521552
name = "ra-ap-rustc_pattern_analysis"
1553-
version = "0.71.0"
1553+
version = "0.73.0"
15541554
source = "registry+https://github.com/rust-lang/crates.io-index"
1555-
checksum = "273d5f72926a58c7eea27aebc898d1d5b32d23d2342f692a94a2cf8746aa4a2f"
1555+
checksum = "6e830862a0ec85fce211d34735315686bb8d6a12d418d6d735fb534aa1cd3293"
15561556
dependencies = [
15571557
"ra-ap-rustc_index",
1558-
"rustc-hash 1.1.0",
1558+
"rustc-hash 2.0.0",
15591559
"rustc_apfloat",
15601560
"smallvec",
15611561
"tracing",

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

+9-11
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)