Merge pull request #18457 from lnicola/sync-from-rust

minor: Sync from downstream
This commit is contained in:
Laurențiu Nicola 2024-11-01 12:26:18 +00:00 committed by GitHub
commit d1fbfc676b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 38 additions and 55 deletions

31
Cargo.lock generated
View file

@ -1364,7 +1364,6 @@ dependencies = [
"proc-macro-api", "proc-macro-api",
"proc-macro-test", "proc-macro-test",
"ra-ap-rustc_lexer", "ra-ap-rustc_lexer",
"snap",
"span", "span",
"stdx", "stdx",
"syntax-bridge", "syntax-bridge",
@ -1493,9 +1492,9 @@ dependencies = [
[[package]] [[package]]
name = "ra-ap-rustc_abi" name = "ra-ap-rustc_abi"
version = "0.75.0" version = "0.76.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5bc2cfc7264d84215a08875ef90a1d35f76b5c9ad1993515d2da7e4e40b2b4b" checksum = "709fde78db053c78c87776ec738677649f791645883f82ff145f68caf9f18e1a"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"ra-ap-rustc_index", "ra-ap-rustc_index",
@ -1504,9 +1503,9 @@ dependencies = [
[[package]] [[package]]
name = "ra-ap-rustc_index" name = "ra-ap-rustc_index"
version = "0.75.0" version = "0.76.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8929140697812e5dd09e19cf446d85146332363f0dbc125d4214834c34ead96" checksum = "da115d496e5abd65e2dceb6883d7597593badfe23fea3439202b8da5a11ea250"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"ra-ap-rustc_index_macros", "ra-ap-rustc_index_macros",
@ -1515,9 +1514,9 @@ dependencies = [
[[package]] [[package]]
name = "ra-ap-rustc_index_macros" name = "ra-ap-rustc_index_macros"
version = "0.75.0" version = "0.76.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "514a3f5d04c8b4a2750f29746cc9abb1f78deb7e72e4ad1dc95bbc608f3db157" checksum = "be86d06a75a8125c1ace197d5030e6e02721348d32e572baea35c891669ad1e2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1526,9 +1525,9 @@ dependencies = [
[[package]] [[package]]
name = "ra-ap-rustc_lexer" name = "ra-ap-rustc_lexer"
version = "0.75.0" version = "0.76.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "276fcb1205da071a0cd64416f3f0e198043c11f176c5b501a45dbf0cb33979f2" checksum = "b64b46ae0d8f59acc32e64e0085532b831f0d6182d870a7cd86c046c2c46e722"
dependencies = [ dependencies = [
"unicode-properties", "unicode-properties",
"unicode-xid", "unicode-xid",
@ -1536,9 +1535,9 @@ dependencies = [
[[package]] [[package]]
name = "ra-ap-rustc_parse_format" name = "ra-ap-rustc_parse_format"
version = "0.75.0" version = "0.76.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "961b30b22cfac296b14b72e9f95e79c16cebc8c926872755fb1568a6c4243a62" checksum = "dbdaad19ddbd0ff46e947ca8dbb6ae678a112d3938669fb3ad6bfd244917e24b"
dependencies = [ dependencies = [
"ra-ap-rustc_index", "ra-ap-rustc_index",
"ra-ap-rustc_lexer", "ra-ap-rustc_lexer",
@ -1546,9 +1545,9 @@ dependencies = [
[[package]] [[package]]
name = "ra-ap-rustc_pattern_analysis" name = "ra-ap-rustc_pattern_analysis"
version = "0.75.0" version = "0.76.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "614232513814a4b714fea7f11345d31c0c277bca3089bb6ca1ec20870bfc022a" checksum = "dc5761e37c78d98ede9f20f6b66526093d0be66aa256d5cbdf214495843ba74d"
dependencies = [ dependencies = [
"ra-ap-rustc_index", "ra-ap-rustc_index",
"rustc-hash 2.0.0", "rustc-hash 2.0.0",
@ -1888,12 +1887,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "snap"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b"
[[package]] [[package]]
name = "span" name = "span"
version = "0.0.0" version = "0.0.0"

View file

@ -84,11 +84,11 @@ tt = { path = "./crates/tt", version = "0.0.0" }
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" } vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
vfs = { path = "./crates/vfs", version = "0.0.0" } vfs = { path = "./crates/vfs", version = "0.0.0" }
ra-ap-rustc_lexer = { version = "0.75", default-features = false } ra-ap-rustc_lexer = { version = "0.76", default-features = false }
ra-ap-rustc_parse_format = { version = "0.75", default-features = false } ra-ap-rustc_parse_format = { version = "0.76", default-features = false }
ra-ap-rustc_index = { version = "0.75", default-features = false } ra-ap-rustc_index = { version = "0.76", default-features = false }
ra-ap-rustc_abi = { version = "0.75", default-features = false } ra-ap-rustc_abi = { version = "0.76", default-features = false }
ra-ap-rustc_pattern_analysis = { version = "0.75", default-features = false } ra-ap-rustc_pattern_analysis = { version = "0.76", default-features = false }
# local crates that aren't published to crates.io. These should not have versions. # local crates that aren't published to crates.io. These should not have versions.
test-fixture = { path = "./crates/test-fixture" } test-fixture = { path = "./crates/test-fixture" }
@ -145,7 +145,6 @@ smallvec = { version = "1.10.0", features = [
"const_generics", "const_generics",
] } ] }
smol_str = "0.3.2" smol_str = "0.3.2"
snap = "1.1.0"
text-size = "1.1.1" text-size = "1.1.1"
tracing = "0.1.40" tracing = "0.1.40"
tracing-tree = "0.3.0" tracing-tree = "0.3.0"

View file

@ -6,8 +6,9 @@ use base_db::ra_salsa::Cycle;
use chalk_ir::{AdtId, FloatTy, IntTy, TyKind, UintTy}; use chalk_ir::{AdtId, FloatTy, IntTy, TyKind, UintTy};
use hir_def::{ use hir_def::{
layout::{ layout::{
Abi, FieldsShape, Float, Integer, LayoutCalculator, LayoutCalculatorError, LayoutData, BackendRepr, FieldsShape, Float, Integer, LayoutCalculator, LayoutCalculatorError,
Primitive, ReprOptions, Scalar, Size, StructKind, TargetDataLayout, WrappingRange, LayoutData, Primitive, ReprOptions, Scalar, Size, StructKind, TargetDataLayout,
WrappingRange,
}, },
LocalFieldId, StructId, LocalFieldId, StructId,
}; };
@ -168,7 +169,7 @@ fn layout_of_simd_ty(
// Compute the ABI of the element type: // Compute the ABI of the element type:
let e_ly = db.layout_of_ty(e_ty, env)?; let e_ly = db.layout_of_ty(e_ty, env)?;
let Abi::Scalar(e_abi) = e_ly.abi else { let BackendRepr::Scalar(e_abi) = e_ly.backend_repr else {
return Err(LayoutError::Unknown); return Err(LayoutError::Unknown);
}; };
@ -190,7 +191,7 @@ fn layout_of_simd_ty(
Ok(Arc::new(Layout { Ok(Arc::new(Layout {
variants: Variants::Single { index: struct_variant_idx() }, variants: Variants::Single { index: struct_variant_idx() },
fields, fields,
abi: Abi::Vector { element: e_abi, count: e_len }, backend_repr: BackendRepr::Vector { element: e_abi, count: e_len },
largest_niche: e_ly.largest_niche, largest_niche: e_ly.largest_niche,
size, size,
align, align,
@ -294,10 +295,11 @@ pub fn layout_of_ty_query(
.checked_mul(count, dl) .checked_mul(count, dl)
.ok_or(LayoutError::BadCalc(LayoutCalculatorError::SizeOverflow))?; .ok_or(LayoutError::BadCalc(LayoutCalculatorError::SizeOverflow))?;
let abi = if count != 0 && matches!(element.abi, Abi::Uninhabited) { let backend_repr =
Abi::Uninhabited if count != 0 && matches!(element.backend_repr, BackendRepr::Uninhabited) {
BackendRepr::Uninhabited
} else { } else {
Abi::Aggregate { sized: true } BackendRepr::Memory { sized: true }
}; };
let largest_niche = if count != 0 { element.largest_niche } else { None }; let largest_niche = if count != 0 { element.largest_niche } else { None };
@ -305,7 +307,7 @@ pub fn layout_of_ty_query(
Layout { Layout {
variants: Variants::Single { index: struct_variant_idx() }, variants: Variants::Single { index: struct_variant_idx() },
fields: FieldsShape::Array { stride: element.size, count }, fields: FieldsShape::Array { stride: element.size, count },
abi, backend_repr,
largest_niche, largest_niche,
align: element.align, align: element.align,
size, size,
@ -318,7 +320,7 @@ pub fn layout_of_ty_query(
Layout { Layout {
variants: Variants::Single { index: struct_variant_idx() }, variants: Variants::Single { index: struct_variant_idx() },
fields: FieldsShape::Array { stride: element.size, count: 0 }, fields: FieldsShape::Array { stride: element.size, count: 0 },
abi: Abi::Aggregate { sized: false }, backend_repr: BackendRepr::Memory { sized: false },
largest_niche: None, largest_niche: None,
align: element.align, align: element.align,
size: Size::ZERO, size: Size::ZERO,
@ -329,7 +331,7 @@ pub fn layout_of_ty_query(
TyKind::Str => Layout { TyKind::Str => Layout {
variants: Variants::Single { index: struct_variant_idx() }, variants: Variants::Single { index: struct_variant_idx() },
fields: FieldsShape::Array { stride: Size::from_bytes(1), count: 0 }, fields: FieldsShape::Array { stride: Size::from_bytes(1), count: 0 },
abi: Abi::Aggregate { sized: false }, backend_repr: BackendRepr::Memory { sized: false },
largest_niche: None, largest_niche: None,
align: dl.i8_align, align: dl.i8_align,
size: Size::ZERO, size: Size::ZERO,
@ -379,8 +381,8 @@ pub fn layout_of_ty_query(
TyKind::Never => cx.calc.layout_of_never_type(), TyKind::Never => cx.calc.layout_of_never_type(),
TyKind::Dyn(_) | TyKind::Foreign(_) => { TyKind::Dyn(_) | TyKind::Foreign(_) => {
let mut unit = layout_of_unit(&cx)?; let mut unit = layout_of_unit(&cx)?;
match &mut unit.abi { match &mut unit.backend_repr {
Abi::Aggregate { sized } => *sized = false, BackendRepr::Memory { sized } => *sized = false,
_ => return Err(LayoutError::Unknown), _ => return Err(LayoutError::Unknown),
} }
unit unit

View file

@ -16,7 +16,6 @@ doctest = false
object.workspace = true object.workspace = true
libloading.workspace = true libloading.workspace = true
memmap2.workspace = true memmap2.workspace = true
snap.workspace = true
stdx.workspace = true stdx.workspace = true
tt.workspace = true tt.workspace = true

View file

@ -8,7 +8,6 @@ use std::{
use memmap2::Mmap; use memmap2::Mmap;
use object::read::{File as BinaryFile, Object, ObjectSection}; use object::read::{File as BinaryFile, Object, ObjectSection};
use paths::AbsPath; use paths::AbsPath;
use snap::read::FrameDecoder as SnapDecoder;
#[derive(Debug)] #[derive(Debug)]
#[allow(dead_code)] #[allow(dead_code)]
@ -123,9 +122,8 @@ pub fn read_version(dylib_path: &AbsPath) -> io::Result<String> {
let version = u32::from_be_bytes([dot_rustc[4], dot_rustc[5], dot_rustc[6], dot_rustc[7]]); let version = u32::from_be_bytes([dot_rustc[4], dot_rustc[5], dot_rustc[6], dot_rustc[7]]);
// Last supported version is: // Last supported version is:
// https://github.com/rust-lang/rust/commit/b94cfefc860715fb2adf72a6955423d384c69318 // https://github.com/rust-lang/rust/commit/b94cfefc860715fb2adf72a6955423d384c69318
let (snappy_portion, bytes_before_version) = match version { let (mut metadata_portion, bytes_before_version) = match version {
5 | 6 => (&dot_rustc[8..], 13), 8 => {
7 | 8 => {
let len_bytes = &dot_rustc[8..12]; let len_bytes = &dot_rustc[8..12];
let data_len = u32::from_be_bytes(len_bytes.try_into().unwrap()) as usize; let data_len = u32::from_be_bytes(len_bytes.try_into().unwrap()) as usize;
(&dot_rustc[12..data_len + 12], 13) (&dot_rustc[12..data_len + 12], 13)
@ -143,13 +141,6 @@ pub fn read_version(dylib_path: &AbsPath) -> io::Result<String> {
} }
}; };
let mut uncompressed: Box<dyn Read> = if &snappy_portion[0..4] == b"rust" {
// Not compressed.
Box::new(snappy_portion)
} else {
Box::new(SnapDecoder::new(snappy_portion))
};
// We're going to skip over the bytes before the version string, so basically: // We're going to skip over the bytes before the version string, so basically:
// 8 bytes for [b'r',b'u',b's',b't',0,0,0,5] // 8 bytes for [b'r',b'u',b's',b't',0,0,0,5]
// 4 or 8 bytes for [crate root bytes] // 4 or 8 bytes for [crate root bytes]
@ -157,11 +148,11 @@ pub fn read_version(dylib_path: &AbsPath) -> io::Result<String> {
// so 13 or 17 bytes in total, and we should check the last of those bytes // so 13 or 17 bytes in total, and we should check the last of those bytes
// to know the length // to know the length
let mut bytes = [0u8; 17]; let mut bytes = [0u8; 17];
uncompressed.read_exact(&mut bytes[..bytes_before_version])?; metadata_portion.read_exact(&mut bytes[..bytes_before_version])?;
let length = bytes[bytes_before_version - 1]; let length = bytes[bytes_before_version - 1];
let mut version_string_utf8 = vec![0u8; length as usize]; let mut version_string_utf8 = vec![0u8; length as usize];
uncompressed.read_exact(&mut version_string_utf8)?; metadata_portion.read_exact(&mut version_string_utf8)?;
let version_string = String::from_utf8(version_string_utf8); let version_string = String::from_utf8(version_string_utf8);
version_string.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e)) version_string.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
} }

View file

@ -1 +1 @@
a9d17627d241645a54c1134a20f1596127fedb60 145f9cf95de1fbde3fa11e98461310e0373253e6

View file

@ -135,7 +135,6 @@ Apache-2.0 WITH LLVM-exception
Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
Apache-2.0/MIT Apache-2.0/MIT
BSD-2-Clause OR Apache-2.0 OR MIT BSD-2-Clause OR Apache-2.0 OR MIT
BSD-3-Clause
CC0-1.0 CC0-1.0
ISC ISC
MIT MIT