mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Replace some LayoutError variants with the rustc_abi errors
This commit is contained in:
parent
8d479d099b
commit
a32039278f
2 changed files with 22 additions and 24 deletions
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -1497,9 +1497,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ra-ap-rustc_abi"
|
name = "ra-ap-rustc_abi"
|
||||||
version = "0.71.0"
|
version = "0.73.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c6999d098000b98415939f13158dac78cb3eeeb7b0c073847f3e4b623866e27c"
|
checksum = "879ece0781e3c1cb670b9f29775c81a43a16db789d1296fad6bc5c74065b2fac"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"ra-ap-rustc_index",
|
"ra-ap-rustc_index",
|
||||||
|
@ -1508,9 +1508,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ra-ap-rustc_index"
|
name = "ra-ap-rustc_index"
|
||||||
version = "0.71.0"
|
version = "0.73.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ae9fb312d942817dab10790881f555928c1f6a11a85186e8e573ad4a86c7d3be"
|
checksum = "6910087ff89bb9f3db114bfcd86b5139042731fe7278d3ff4ceaa69a140154a7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"ra-ap-rustc_index_macros",
|
"ra-ap-rustc_index_macros",
|
||||||
|
@ -1519,9 +1519,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ra-ap-rustc_index_macros"
|
name = "ra-ap-rustc_index_macros"
|
||||||
version = "0.71.0"
|
version = "0.73.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "766e3990eb1066a06deefc561b5a01b32ca5c9211feea31cbf4ed50611519872"
|
checksum = "3b6f7bd12b678fbb37444ba77f3b0cfc13b7394a6dc7b0c799491fc9df0a9997"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -1530,9 +1530,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ra-ap-rustc_lexer"
|
name = "ra-ap-rustc_lexer"
|
||||||
version = "0.71.0"
|
version = "0.73.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f4afa98eb7889c137d5a3f1cd189089e16da04d1e4837d358a67aa3dab10ffbe"
|
checksum = "119bc05b5b6bc3e7f5b67ce8b8080e185da94bd83c447f91b6b3f3ecf60cbab1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-properties",
|
"unicode-properties",
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
|
@ -1540,9 +1540,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ra-ap-rustc_parse_format"
|
name = "ra-ap-rustc_parse_format"
|
||||||
version = "0.71.0"
|
version = "0.73.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d9234c96ffb0565286790407fb7eb7f55ebf69267de4db382fdec0a17f14b0e2"
|
checksum = "70ed6150ae71d905c064dc88d7824ebb0fa81083f45d7477cba7b57176f2f635"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ra-ap-rustc_index",
|
"ra-ap-rustc_index",
|
||||||
"ra-ap-rustc_lexer",
|
"ra-ap-rustc_lexer",
|
||||||
|
@ -1550,12 +1550,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ra-ap-rustc_pattern_analysis"
|
name = "ra-ap-rustc_pattern_analysis"
|
||||||
version = "0.71.0"
|
version = "0.73.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "273d5f72926a58c7eea27aebc898d1d5b32d23d2342f692a94a2cf8746aa4a2f"
|
checksum = "6e830862a0ec85fce211d34735315686bb8d6a12d418d6d735fb534aa1cd3293"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ra-ap-rustc_index",
|
"ra-ap-rustc_index",
|
||||||
"rustc-hash 1.1.0",
|
"rustc-hash 2.0.0",
|
||||||
"rustc_apfloat",
|
"rustc_apfloat",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
|
|
@ -72,18 +72,15 @@ pub type Variants = hir_def::layout::Variants<RustcFieldIdx, RustcEnumVariantIdx
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
pub enum LayoutError {
|
pub enum LayoutError {
|
||||||
// FIXME: Remove variants that duplicate LayoutCalculatorError's variants after sync
|
// FIXME: Remove more variants once they get added to LayoutCalculatorError
|
||||||
BadCalc(LayoutCalculatorError<()>),
|
BadCalc(LayoutCalculatorError<()>),
|
||||||
EmptyUnion,
|
|
||||||
HasErrorConst,
|
HasErrorConst,
|
||||||
HasErrorType,
|
HasErrorType,
|
||||||
HasPlaceholder,
|
HasPlaceholder,
|
||||||
InvalidSimdType,
|
InvalidSimdType,
|
||||||
NotImplemented,
|
NotImplemented,
|
||||||
RecursiveTypeWithoutIndirection,
|
RecursiveTypeWithoutIndirection,
|
||||||
SizeOverflow,
|
|
||||||
TargetLayoutNotAvailable,
|
TargetLayoutNotAvailable,
|
||||||
UnexpectedUnsized,
|
|
||||||
Unknown,
|
Unknown,
|
||||||
UserReprTooSmall,
|
UserReprTooSmall,
|
||||||
}
|
}
|
||||||
|
@ -93,7 +90,6 @@ impl fmt::Display for LayoutError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
LayoutError::BadCalc(err) => err.fallback_fmt(f),
|
LayoutError::BadCalc(err) => err.fallback_fmt(f),
|
||||||
LayoutError::EmptyUnion => write!(f, "type is an union with no fields"),
|
|
||||||
LayoutError::HasErrorConst => write!(f, "type contains an unevaluatable const"),
|
LayoutError::HasErrorConst => write!(f, "type contains an unevaluatable const"),
|
||||||
LayoutError::HasErrorType => write!(f, "type contains an error"),
|
LayoutError::HasErrorType => write!(f, "type contains an error"),
|
||||||
LayoutError::HasPlaceholder => write!(f, "type contains placeholders"),
|
LayoutError::HasPlaceholder => write!(f, "type contains placeholders"),
|
||||||
|
@ -102,11 +98,7 @@ impl fmt::Display for LayoutError {
|
||||||
LayoutError::RecursiveTypeWithoutIndirection => {
|
LayoutError::RecursiveTypeWithoutIndirection => {
|
||||||
write!(f, "recursive type without indirection")
|
write!(f, "recursive type without indirection")
|
||||||
}
|
}
|
||||||
LayoutError::SizeOverflow => write!(f, "size overflow"),
|
|
||||||
LayoutError::TargetLayoutNotAvailable => write!(f, "target layout not available"),
|
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::Unknown => write!(f, "unknown"),
|
||||||
LayoutError::UserReprTooSmall => {
|
LayoutError::UserReprTooSmall => {
|
||||||
write!(f, "the `#[repr]` hint is too small to hold the discriminants of the enum")
|
write!(f, "the `#[repr]` hint is too small to hold the discriminants of the enum")
|
||||||
|
@ -181,7 +173,10 @@ fn layout_of_simd_ty(
|
||||||
};
|
};
|
||||||
|
|
||||||
// Compute the size and alignment of the vector:
|
// 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 align = dl.vector_align(size);
|
||||||
let size = size.align_to(align.abi);
|
let size = size.align_to(align.abi);
|
||||||
|
|
||||||
|
@ -294,7 +289,10 @@ pub fn layout_of_ty_query(
|
||||||
TyKind::Array(element, count) => {
|
TyKind::Array(element, count) => {
|
||||||
let count = try_const_usize(db, count).ok_or(LayoutError::HasErrorConst)? as u64;
|
let count = try_const_usize(db, count).ok_or(LayoutError::HasErrorConst)? as u64;
|
||||||
let element = db.layout_of_ty(element.clone(), trait_env)?;
|
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) {
|
let abi = if count != 0 && matches!(element.abi, Abi::Uninhabited) {
|
||||||
Abi::Uninhabited
|
Abi::Uninhabited
|
||||||
|
|
Loading…
Reference in a new issue