From 4d0c1ee1bdc1f6e319515a6f78177052d366214b Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Thu, 27 Feb 2025 08:21:47 +0000 Subject: [PATCH 1/9] Delete tuple unsizing --- crates/ide-db/src/generated/lints.rs | 34 ---------------------------- 1 file changed, 34 deletions(-) diff --git a/crates/ide-db/src/generated/lints.rs b/crates/ide-db/src/generated/lints.rs index ed9d6c6750..9c983e7c4a 100644 --- a/crates/ide-db/src/generated/lints.rs +++ b/crates/ide-db/src/generated/lints.rs @@ -12311,40 +12311,6 @@ fn main() { ``` will unnecessarily extend the stack frame. -"##, - default_severity: Severity::Allow, - warn_since: None, - deny_since: None, - }, - Lint { - label: "unsized_tuple_coercion", - description: r##"# `unsized_tuple_coercion` - -The tracking issue for this feature is: [#42877] - -[#42877]: https://github.com/rust-lang/rust/issues/42877 - ------------------------- - -This is a part of [RFC0401]. According to the RFC, there should be an implementation like this: - -```rust,ignore (partial-example) -impl<..., T, U: ?Sized> Unsized<(..., U)> for (..., T) where T: Unsized {} -``` - -This implementation is currently gated behind `#[feature(unsized_tuple_coercion)]` to avoid insta-stability. Therefore you can use it like this: - -```rust -#![feature(unsized_tuple_coercion)] - -fn main() { - let x : ([i32; 3], [i32; 3]) = ([1, 2, 3], [4, 5, 6]); - let y : &([i32; 3], [i32]) = &x; - assert_eq!(y.1[0], 4); -} -``` - -[RFC0401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md "##, default_severity: Severity::Allow, warn_since: None, From c64ed1e1871d5f1f503521e9d3086368c0ea8904 Mon Sep 17 00:00:00 2001 From: Moulins Date: Sat, 1 Mar 2025 12:40:06 +0100 Subject: [PATCH 2/9] Remove layouting dead code for non-array SIMD types. These aren't supported anymore, and are already rejected in type checking. --- crates/hir-ty/src/layout.rs | 47 +++++++++---------------------------- 1 file changed, 11 insertions(+), 36 deletions(-) diff --git a/crates/hir-ty/src/layout.rs b/crates/hir-ty/src/layout.rs index a4e49e0aa1..7af31dabe4 100644 --- a/crates/hir-ty/src/layout.rs +++ b/crates/hir-ty/src/layout.rs @@ -133,40 +133,22 @@ fn layout_of_simd_ty( env: Arc, dl: &TargetDataLayout, ) -> Result, LayoutError> { - let fields = db.field_types(id.into()); - - // Supported SIMD vectors are homogeneous ADTs with at least one field: + // Supported SIMD vectors are homogeneous ADTs with exactly one array field: // - // * #[repr(simd)] struct S(T, T, T, T); - // * #[repr(simd)] struct S { it: T, y: T, z: T, w: T } // * #[repr(simd)] struct S([T; 4]) // // where T is a primitive scalar (integer/float/pointer). - - let f0_ty = match fields.iter().next() { - Some(it) => it.1.clone().substitute(Interner, subst), - None => return Err(LayoutError::InvalidSimdType), + let fields = db.field_types(id.into()); + let mut fields = fields.iter(); + let Some(TyKind::Array(e_ty, e_len)) = fields + .next() + .filter(|_| fields.next().is_none()) + .map(|f| f.1.clone().substitute(Interner, subst).kind(Interner).clone()) + else { + return Err(LayoutError::InvalidSimdType); }; - // The element type and number of elements of the SIMD vector - // are obtained from: - // - // * the element type and length of the single array field, if - // the first field is of array type, or - // - // * the homogeneous field type and the number of fields. - let (e_ty, e_len, is_array) = if let TyKind::Array(e_ty, _) = f0_ty.kind(Interner) { - // Extract the number of elements from the layout of the array field: - let FieldsShape::Array { count, .. } = db.layout_of_ty(f0_ty.clone(), env.clone())?.fields - else { - return Err(LayoutError::Unknown); - }; - - (e_ty.clone(), count, true) - } else { - // First ADT field is not an array: - (f0_ty, fields.iter().count() as u64, false) - }; + let e_len = try_const_usize(db, &e_len).ok_or(LayoutError::HasErrorConst)? as u64; // Compute the ABI of the element type: let e_ly = db.layout_of_ty(e_ty, env)?; @@ -182,16 +164,9 @@ fn layout_of_simd_ty( let align = dl.llvmlike_vector_align(size); let size = size.align_to(align.abi); - // Compute the placement of the vector fields: - let fields = if is_array { - FieldsShape::Arbitrary { offsets: [Size::ZERO].into(), memory_index: [0].into() } - } else { - FieldsShape::Array { stride: e_ly.size, count: e_len } - }; - Ok(Arc::new(Layout { variants: Variants::Single { index: struct_variant_idx() }, - fields, + fields: FieldsShape::Arbitrary { offsets: [Size::ZERO].into(), memory_index: [0].into() }, backend_repr: BackendRepr::SimdVector { element: e_abi, count: e_len }, largest_niche: e_ly.largest_niche, uninhabited: false, From 22fff683c44c69d1cdaf9d05b994cae6007fc534 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 10 Feb 2025 10:41:19 -0800 Subject: [PATCH 3/9] Update stdarch --- lib/line-index/src/lib.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/line-index/src/lib.rs b/lib/line-index/src/lib.rs index bc87ada3eb..905da330e6 100644 --- a/lib/line-index/src/lib.rs +++ b/lib/line-index/src/lib.rs @@ -257,6 +257,8 @@ fn analyze_source_file_dispatch( /// SSE2 intrinsics to quickly find all newlines. #[target_feature(enable = "sse2")] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +// This can be removed once 1.87 is stable due to some intrinsics switching to safe. +#[allow(unsafe_op_in_unsafe_fn)] unsafe fn analyze_source_file_sse2( src: &str, lines: &mut Vec, @@ -287,17 +289,17 @@ unsafe fn analyze_source_file_sse2( // For character in the chunk, see if its byte value is < 0, which // indicates that it's part of a UTF-8 char. - let multibyte_test = unsafe { _mm_cmplt_epi8(chunk, _mm_set1_epi8(0)) }; + let multibyte_test = _mm_cmplt_epi8(chunk, _mm_set1_epi8(0)); // Create a bit mask from the comparison results. - let multibyte_mask = unsafe { _mm_movemask_epi8(multibyte_test) }; + let multibyte_mask = _mm_movemask_epi8(multibyte_test); // If the bit mask is all zero, we only have ASCII chars here: if multibyte_mask == 0 { assert!(intra_chunk_offset == 0); // Check for newlines in the chunk - let newlines_test = unsafe { _mm_cmpeq_epi8(chunk, _mm_set1_epi8(b'\n' as i8)) }; - let newlines_mask = unsafe { _mm_movemask_epi8(newlines_test) }; + let newlines_test = _mm_cmpeq_epi8(chunk, _mm_set1_epi8(b'\n' as i8)); + let newlines_mask = _mm_movemask_epi8(newlines_test); if newlines_mask != 0 { // All control characters are newlines, record them @@ -354,15 +356,19 @@ unsafe fn analyze_source_file_sse2( // The mask is a 64-bit integer, where each 4-bit corresponds to a u8 in the // input vector. The least significant 4 bits correspond to the first byte in // the vector. +// This can be removed once 1.87 is stable due to some intrinsics switching to safe. +#[allow(unsafe_op_in_unsafe_fn)] unsafe fn move_mask(v: std::arch::aarch64::uint8x16_t) -> u64 { use std::arch::aarch64::*; - let nibble_mask = unsafe { vshrn_n_u16(vreinterpretq_u16_u8(v), 4) }; - unsafe { vget_lane_u64(vreinterpret_u64_u8(nibble_mask), 0) } + let nibble_mask = vshrn_n_u16(vreinterpretq_u16_u8(v), 4); + vget_lane_u64(vreinterpret_u64_u8(nibble_mask), 0) } #[target_feature(enable = "neon")] #[cfg(all(target_arch = "aarch64", target_endian = "little"))] +// This can be removed once 1.87 is stable due to some intrinsics switching to safe. +#[allow(unsafe_op_in_unsafe_fn)] unsafe fn analyze_source_file_neon( src: &str, lines: &mut Vec, @@ -376,7 +382,7 @@ unsafe fn analyze_source_file_neon( let chunk_count = src.len() / CHUNK_SIZE; - let newline = unsafe { vdupq_n_s8(b'\n' as i8) }; + let newline = vdupq_n_s8(b'\n' as i8); // This variable keeps track of where we should start decoding a // chunk. If a multi-byte character spans across chunk boundaries, @@ -390,7 +396,7 @@ unsafe fn analyze_source_file_neon( // For character in the chunk, see if its byte value is < 0, which // indicates that it's part of a UTF-8 char. - let multibyte_test = unsafe { vcltzq_s8(chunk) }; + let multibyte_test = vcltzq_s8(chunk); // Create a bit mask from the comparison results. let multibyte_mask = unsafe { move_mask(multibyte_test) }; @@ -399,7 +405,7 @@ unsafe fn analyze_source_file_neon( assert!(intra_chunk_offset == 0); // Check for newlines in the chunk - let newlines_test = unsafe { vceqq_s8(chunk, newline) }; + let newlines_test = vceqq_s8(chunk, newline); let mut newlines_mask = unsafe { move_mask(newlines_test) }; // If the bit mask is not all zero, there are newlines in this chunk. From 4929f38544fd8c0b8cc30220ab0f6e13b3788de0 Mon Sep 17 00:00:00 2001 From: Moulins Date: Fri, 28 Feb 2025 04:57:17 +0100 Subject: [PATCH 4/9] Remove most manual LayoutData creations and move them to `rustc_abi` ...either as: - methods on LayoutCalculator, for faillible operations; - constructors on LayoutData, for infaillible ones. --- crates/hir-ty/src/layout.rs | 98 ++++++++----------------------------- 1 file changed, 20 insertions(+), 78 deletions(-) diff --git a/crates/hir-ty/src/layout.rs b/crates/hir-ty/src/layout.rs index 7af31dabe4..05f38cd09e 100644 --- a/crates/hir-ty/src/layout.rs +++ b/crates/hir-ty/src/layout.rs @@ -15,7 +15,7 @@ use hir_def::{ use la_arena::{Idx, RawIdx}; use rustc_abi::AddressSpace; use rustc_hashes::Hash64; -use rustc_index::{IndexSlice, IndexVec}; +use rustc_index::IndexVec; use triomphe::Arc; @@ -190,7 +190,8 @@ pub fn layout_of_ty_query( let dl = &*target; let cx = LayoutCx::new(dl); let ty = normalize(db, trait_env.clone(), ty); - let result = match ty.kind(Interner) { + let kind = ty.kind(Interner); + let result = match kind { TyKind::Adt(AdtId(def), subst) => { if let hir_def::AdtId::StructId(s) = def { let data = db.struct_data(*s); @@ -216,7 +217,7 @@ pub fn layout_of_ty_query( valid_range: WrappingRange { start: 0, end: 0x10FFFF }, }, ), - chalk_ir::Scalar::Int(i) => scalar( + chalk_ir::Scalar::Int(i) => Layout::scalar(dl, scalar_unit( dl, Primitive::Int( match i { @@ -229,8 +230,8 @@ pub fn layout_of_ty_query( }, true, ), - ), - chalk_ir::Scalar::Uint(i) => scalar( + )), + chalk_ir::Scalar::Uint(i) => Layout::scalar(dl, scalar_unit( dl, Primitive::Int( match i { @@ -243,8 +244,8 @@ pub fn layout_of_ty_query( }, false, ), - ), - chalk_ir::Scalar::Float(f) => scalar( + )), + chalk_ir::Scalar::Float(f) => Layout::scalar(dl, scalar_unit( dl, Primitive::Float(match f { FloatTy::F16 => Float::F16, @@ -252,7 +253,7 @@ pub fn layout_of_ty_query( FloatTy::F64 => Float::F64, FloatTy::F128 => Float::F128, }), - ), + )), }, TyKind::Tuple(len, tys) => { let kind = if *len == 0 { StructKind::AlwaysSized } else { StructKind::MaybeUnsized }; @@ -268,56 +269,16 @@ 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::BadCalc(LayoutCalculatorError::SizeOverflow))?; - - let backend_repr = BackendRepr::Memory { sized: true }; - - let largest_niche = if count != 0 { element.largest_niche } else { None }; - let uninhabited = if count != 0 { element.uninhabited } else { false }; - - Layout { - variants: Variants::Single { index: struct_variant_idx() }, - fields: FieldsShape::Array { stride: element.size, count }, - backend_repr, - largest_niche, - uninhabited, - align: element.align, - size, - max_repr_align: None, - unadjusted_abi_align: element.align.abi, - randomization_seed: Hash64::ZERO, - } + cx.calc.array_like::<_, _, ()>(&element, Some(count))? } TyKind::Slice(element) => { let element = db.layout_of_ty(element.clone(), trait_env)?; - Layout { - variants: Variants::Single { index: struct_variant_idx() }, - fields: FieldsShape::Array { stride: element.size, count: 0 }, - backend_repr: BackendRepr::Memory { sized: false }, - largest_niche: None, - uninhabited: false, - align: element.align, - size: Size::ZERO, - max_repr_align: None, - unadjusted_abi_align: element.align.abi, - randomization_seed: Hash64::ZERO, - } + cx.calc.array_like::<_, _, ()>(&element, None)? + } + TyKind::Str => { + let element = scalar_unit(dl, Primitive::Int(Integer::I8, false)); + cx.calc.array_like::<_, _, ()>(&Layout::scalar(dl, element), None)? } - TyKind::Str => Layout { - variants: Variants::Single { index: struct_variant_idx() }, - fields: FieldsShape::Array { stride: Size::from_bytes(1), count: 0 }, - backend_repr: BackendRepr::Memory { sized: false }, - largest_niche: None, - uninhabited: false, - align: dl.i8_align, - size: Size::ZERO, - max_repr_align: None, - unadjusted_abi_align: dl.i8_align.abi, - randomization_seed: Hash64::ZERO, - }, // Potentially-wide pointers. TyKind::Ref(_, _, pointee) | TyKind::Raw(_, pointee) => { let mut data_ptr = scalar_unit(dl, Primitive::Pointer(AddressSpace::DATA)); @@ -355,17 +316,12 @@ pub fn layout_of_ty_query( }; // Effectively a (ptr, meta) tuple. - cx.calc.scalar_pair(data_ptr, metadata) + LayoutData::scalar_pair(dl, data_ptr, metadata) } - TyKind::FnDef(_, _) => layout_of_unit(&cx)?, - TyKind::Never => cx.calc.layout_of_never_type(), - TyKind::Dyn(_) | TyKind::Foreign(_) => { - let mut unit = layout_of_unit(&cx)?; - match &mut unit.backend_repr { - BackendRepr::Memory { sized } => *sized = false, - _ => return Err(LayoutError::Unknown), - } - unit + TyKind::Never => LayoutData::never_type(dl), + TyKind::FnDef(..) | TyKind::Dyn(_) | TyKind::Foreign(_) => { + let sized = matches!(kind, TyKind::FnDef(..)); + LayoutData::unit(dl, sized) } TyKind::Function(_) => { let mut ptr = scalar_unit(dl, Primitive::Pointer(dl.instruction_address_space)); @@ -434,16 +390,6 @@ pub fn layout_of_ty_recover( Err(LayoutError::RecursiveTypeWithoutIndirection) } -fn layout_of_unit(cx: &LayoutCx<'_>) -> Result { - cx.calc - .univariant::( - IndexSlice::empty(), - &ReprOptions::default(), - StructKind::AlwaysSized, - ) - .map_err(Into::into) -} - fn struct_tail_erasing_lifetimes(db: &dyn HirDatabase, pointee: Ty) -> Ty { match pointee.kind(Interner) { TyKind::Adt(AdtId(hir_def::AdtId::StructId(i)), subst) => { @@ -474,9 +420,5 @@ fn scalar_unit(dl: &TargetDataLayout, value: Primitive) -> Scalar { Scalar::Initialized { value, valid_range: WrappingRange::full(value.size(dl)) } } -fn scalar(dl: &TargetDataLayout, value: Primitive) -> Layout { - Layout::scalar(dl, scalar_unit(dl, value)) -} - #[cfg(test)] mod tests; From 18772836d4cbfa1ee0c6c4e91363b7b25ecd0266 Mon Sep 17 00:00:00 2001 From: Moulins Date: Fri, 7 Mar 2025 21:18:18 +0100 Subject: [PATCH 5/9] Use `rustc_abi` code for SIMD layout in rust-analyzer --- crates/hir-ty/src/layout.rs | 37 ++++++--------------------------- crates/hir-ty/src/layout/adt.rs | 6 +----- crates/hir-ty/src/lib.rs | 3 --- 3 files changed, 7 insertions(+), 39 deletions(-) diff --git a/crates/hir-ty/src/layout.rs b/crates/hir-ty/src/layout.rs index 05f38cd09e..2ac1792ba8 100644 --- a/crates/hir-ty/src/layout.rs +++ b/crates/hir-ty/src/layout.rs @@ -6,15 +6,14 @@ use base_db::ra_salsa::Cycle; use chalk_ir::{AdtId, FloatTy, IntTy, TyKind, UintTy}; use hir_def::{ layout::{ - BackendRepr, FieldsShape, Float, Integer, LayoutCalculator, LayoutCalculatorError, - LayoutData, Primitive, ReprOptions, Scalar, Size, StructKind, TargetDataLayout, + Float, Integer, LayoutCalculator, LayoutCalculatorError, + LayoutData, Primitive, ReprOptions, Scalar, StructKind, TargetDataLayout, WrappingRange, }, LocalFieldId, StructId, }; use la_arena::{Idx, RawIdx}; use rustc_abi::AddressSpace; -use rustc_hashes::Hash64; use rustc_index::IndexVec; use triomphe::Arc; @@ -23,7 +22,6 @@ use crate::{ consteval::try_const_usize, db::{HirDatabase, InternedClosure}, infer::normalize, - layout::adt::struct_variant_idx, utils::ClosureSubst, Interner, ProjectionTy, Substitution, TraitEnvironment, Ty, }; @@ -125,10 +123,10 @@ impl<'a> LayoutCx<'a> { } } -// FIXME: move this to the `rustc_abi`. fn layout_of_simd_ty( db: &dyn HirDatabase, id: StructId, + repr_packed: bool, subst: &Substitution, env: Arc, dl: &TargetDataLayout, @@ -149,33 +147,10 @@ fn layout_of_simd_ty( }; let e_len = try_const_usize(db, &e_len).ok_or(LayoutError::HasErrorConst)? as u64; - - // Compute the ABI of the element type: let e_ly = db.layout_of_ty(e_ty, env)?; - let BackendRepr::Scalar(e_abi) = e_ly.backend_repr else { - return Err(LayoutError::Unknown); - }; - // Compute the size and alignment of the vector: - let size = e_ly - .size - .checked_mul(e_len, dl) - .ok_or(LayoutError::BadCalc(LayoutCalculatorError::SizeOverflow))?; - let align = dl.llvmlike_vector_align(size); - let size = size.align_to(align.abi); - - Ok(Arc::new(Layout { - variants: Variants::Single { index: struct_variant_idx() }, - fields: FieldsShape::Arbitrary { offsets: [Size::ZERO].into(), memory_index: [0].into() }, - backend_repr: BackendRepr::SimdVector { element: e_abi, count: e_len }, - largest_niche: e_ly.largest_niche, - uninhabited: false, - size, - align, - max_repr_align: None, - unadjusted_abi_align: align.abi, - randomization_seed: Hash64::ZERO, - })) + let cx = LayoutCx::new(dl); + Ok(Arc::new(cx.calc.simd_type(e_ly, e_len, repr_packed)?)) } pub fn layout_of_ty_query( @@ -197,7 +172,7 @@ pub fn layout_of_ty_query( let data = db.struct_data(*s); let repr = data.repr.unwrap_or_default(); if repr.simd() { - return layout_of_simd_ty(db, *s, subst, trait_env, &target); + return layout_of_simd_ty(db, *s, repr.packed(), subst, trait_env, &target); } }; return db.layout_of_adt(*def, subst.clone(), trait_env); diff --git a/crates/hir-ty/src/layout/adt.rs b/crates/hir-ty/src/layout/adt.rs index 0ba765bd75..eb4729fab8 100644 --- a/crates/hir-ty/src/layout/adt.rs +++ b/crates/hir-ty/src/layout/adt.rs @@ -16,16 +16,12 @@ use triomphe::Arc; use crate::{ db::HirDatabase, lang_items::is_unsafe_cell, - layout::{field_ty, Layout, LayoutError, RustcEnumVariantIdx}, + layout::{field_ty, Layout, LayoutError}, Substitution, TraitEnvironment, }; use super::LayoutCx; -pub(crate) fn struct_variant_idx() -> RustcEnumVariantIdx { - RustcEnumVariantIdx(0) -} - pub fn layout_of_adt_query( db: &dyn HirDatabase, def: AdtId, diff --git a/crates/hir-ty/src/lib.rs b/crates/hir-ty/src/lib.rs index 707c437772..e0dcc01821 100644 --- a/crates/hir-ty/src/lib.rs +++ b/crates/hir-ty/src/lib.rs @@ -12,9 +12,6 @@ extern crate ra_ap_rustc_index as rustc_index; #[cfg(feature = "in-rust-tree")] extern crate rustc_abi; -#[cfg(feature = "in-rust-tree")] -extern crate rustc_hashes; - #[cfg(not(feature = "in-rust-tree"))] extern crate ra_ap_rustc_abi as rustc_abi; From ae1a648915e1eea75afbeb4351ba9f8ae6f9f8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 10 Mar 2025 10:41:28 +0200 Subject: [PATCH 6/9] Preparing for merge from rust-lang/rust --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index e24e08d068..0db4be8ff6 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -daf59857d6d2b87af4b846316bf1561a6083ed51 +2c6a12ec44d0426c8939123c2f2cf27d2217de13 From bc178ff75ea455518d310a9dd1de0695adb7dab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 10 Mar 2025 11:20:56 +0200 Subject: [PATCH 7/9] Bump rustc crates --- Cargo.lock | 29 ++++++++++++++--------------- Cargo.toml | 12 ++++++------ crates/hir-ty/Cargo.toml | 1 - crates/hir-ty/src/lib.rs | 3 --- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c57953ba65..5ff46abcfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -626,7 +626,6 @@ dependencies = [ "oorandom", "project-model", "ra-ap-rustc_abi", - "ra-ap-rustc_hashes", "ra-ap-rustc_index", "ra-ap-rustc_pattern_analysis", "rustc-hash 2.0.0", @@ -1504,9 +1503,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_abi" -version = "0.98.0" +version = "0.100.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b42cccfff8091a4c3397736518774dbad619e82f8def6f70d8e46dbbe396007" +checksum = "f1651b0f7e8c3eb7c27a88f39d277e69c32bfe58e3be174d286c1a24d6a7a4d8" dependencies = [ "bitflags 2.7.0", "ra-ap-rustc_hashes", @@ -1516,18 +1515,18 @@ dependencies = [ [[package]] name = "ra-ap-rustc_hashes" -version = "0.98.0" +version = "0.100.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46d8bd34ed6552c8cac1764106ef5adbeef3e5c7700e0ceb4c83a47a631894fe" +checksum = "2bcd85e93dc0ea850bcfe7957a115957df799ccbc9eea488bdee5ec6780d212b" dependencies = [ "rustc-stable-hash", ] [[package]] name = "ra-ap-rustc_index" -version = "0.98.0" +version = "0.100.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93799e4dccbbd47f8b66bc0aa42effc1b7077aaee09d8a40b86b8d659b80c7b7" +checksum = "62b295fc0640cd9fe0ecab872ee4a17a96f90a3998ec9f0c4765e9b8415c12cc" dependencies = [ "ra-ap-rustc_index_macros", "smallvec", @@ -1535,9 +1534,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_index_macros" -version = "0.98.0" +version = "0.100.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30baa5d00f94ba437a9dcaf7ae074ebe4f367bb05a4c2835e0aa2e7af3463aac" +checksum = "c675f4257023aa933882906f13802cae287e88cc39ab13cbb96809083db0c801" dependencies = [ "proc-macro2", "quote", @@ -1546,9 +1545,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_lexer" -version = "0.98.0" +version = "0.100.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3004d1d1b50afe3e1f9cdd428a282da7ffbf5f26dd8bf04af0d651d44e4873d8" +checksum = "c8358702c2a510ea84ba5801ddc047d9ad9520902cfb0e6173277610cdce2c9c" dependencies = [ "memchr", "unicode-properties", @@ -1557,9 +1556,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_parse_format" -version = "0.98.0" +version = "0.100.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb57e5124a64aaaf92c06130fbc1b8e1d547b5a2a96081f1f848e31c211df5d2" +checksum = "b98f402011d46732c35c47bfd111dec0495747fef2ec900ddee7fe15d78449a7" dependencies = [ "ra-ap-rustc_index", "ra-ap-rustc_lexer", @@ -1567,9 +1566,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_pattern_analysis" -version = "0.98.0" +version = "0.100.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e427c3d30e4bdff28abd6b0ef3e6f4dfab44acd9468a4954eeff8717d8df8819" +checksum = "bef3ff73fa4653252ffe1d1e9177a446f49ef46d97140e4816b7ff2dad59ed53" dependencies = [ "ra-ap-rustc_index", "rustc-hash 2.0.0", diff --git a/Cargo.toml b/Cargo.toml index 1132acb647..70b6544334 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,12 +85,12 @@ vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" } vfs = { path = "./crates/vfs", version = "0.0.0" } edition = { path = "./crates/edition", version = "0.0.0" } -ra-ap-rustc_hashes = { version = "0.98", default-features = false } -ra-ap-rustc_lexer = { version = "0.98", default-features = false } -ra-ap-rustc_parse_format = { version = "0.98", default-features = false } -ra-ap-rustc_index = { version = "0.98", default-features = false } -ra-ap-rustc_abi = { version = "0.98", default-features = false } -ra-ap-rustc_pattern_analysis = { version = "0.98", default-features = false } +ra-ap-rustc_hashes = { version = "0.100", default-features = false } +ra-ap-rustc_lexer = { version = "0.100", default-features = false } +ra-ap-rustc_parse_format = { version = "0.100", default-features = false } +ra-ap-rustc_index = { version = "0.100", default-features = false } +ra-ap-rustc_abi = { version = "0.100", default-features = false } +ra-ap-rustc_pattern_analysis = { version = "0.100", default-features = false } # local crates that aren't published to crates.io. These should not have versions. diff --git a/crates/hir-ty/Cargo.toml b/crates/hir-ty/Cargo.toml index 27849f3b44..1d12bee646 100644 --- a/crates/hir-ty/Cargo.toml +++ b/crates/hir-ty/Cargo.toml @@ -35,7 +35,6 @@ indexmap.workspace = true rustc_apfloat = "0.2.0" ra-ap-rustc_abi.workspace = true -ra-ap-rustc_hashes.workspace = true ra-ap-rustc_index.workspace = true ra-ap-rustc_pattern_analysis.workspace = true diff --git a/crates/hir-ty/src/lib.rs b/crates/hir-ty/src/lib.rs index e0dcc01821..f636de479c 100644 --- a/crates/hir-ty/src/lib.rs +++ b/crates/hir-ty/src/lib.rs @@ -21,9 +21,6 @@ extern crate rustc_pattern_analysis; #[cfg(not(feature = "in-rust-tree"))] extern crate ra_ap_rustc_pattern_analysis as rustc_pattern_analysis; -#[cfg(not(feature = "in-rust-tree"))] -extern crate ra_ap_rustc_hashes as rustc_hashes; - mod builder; mod chalk_db; mod chalk_ext; From 1afcab1725409c0bc09b5c2aaf06fd215a10cd8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 10 Mar 2025 11:21:03 +0200 Subject: [PATCH 8/9] Fix simd layout test --- crates/hir-ty/src/layout/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/hir-ty/src/layout/tests.rs b/crates/hir-ty/src/layout/tests.rs index 4d3896660b..8b74b7328b 100644 --- a/crates/hir-ty/src/layout/tests.rs +++ b/crates/hir-ty/src/layout/tests.rs @@ -342,7 +342,7 @@ fn simd_types() { check_size_and_align( r#" #[repr(simd)] - struct SimdType(i64, i64); + struct SimdType([i64; 2]); struct Goal(SimdType); "#, "", From 25e4bd1f9075cd26569b7508270c08076dc237b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 10 Mar 2025 11:37:21 +0200 Subject: [PATCH 9/9] Format code --- crates/hir-ty/src/layout.rs | 78 ++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/crates/hir-ty/src/layout.rs b/crates/hir-ty/src/layout.rs index 2ac1792ba8..ba36c279f7 100644 --- a/crates/hir-ty/src/layout.rs +++ b/crates/hir-ty/src/layout.rs @@ -6,9 +6,8 @@ use base_db::ra_salsa::Cycle; use chalk_ir::{AdtId, FloatTy, IntTy, TyKind, UintTy}; use hir_def::{ layout::{ - Float, Integer, LayoutCalculator, LayoutCalculatorError, - LayoutData, Primitive, ReprOptions, Scalar, StructKind, TargetDataLayout, - WrappingRange, + Float, Integer, LayoutCalculator, LayoutCalculatorError, LayoutData, Primitive, + ReprOptions, Scalar, StructKind, TargetDataLayout, WrappingRange, }, LocalFieldId, StructId, }; @@ -192,43 +191,52 @@ pub fn layout_of_ty_query( valid_range: WrappingRange { start: 0, end: 0x10FFFF }, }, ), - chalk_ir::Scalar::Int(i) => Layout::scalar(dl, scalar_unit( + chalk_ir::Scalar::Int(i) => Layout::scalar( dl, - Primitive::Int( - match i { - IntTy::Isize => dl.ptr_sized_integer(), - IntTy::I8 => Integer::I8, - IntTy::I16 => Integer::I16, - IntTy::I32 => Integer::I32, - IntTy::I64 => Integer::I64, - IntTy::I128 => Integer::I128, - }, - true, + scalar_unit( + dl, + Primitive::Int( + match i { + IntTy::Isize => dl.ptr_sized_integer(), + IntTy::I8 => Integer::I8, + IntTy::I16 => Integer::I16, + IntTy::I32 => Integer::I32, + IntTy::I64 => Integer::I64, + IntTy::I128 => Integer::I128, + }, + true, + ), ), - )), - chalk_ir::Scalar::Uint(i) => Layout::scalar(dl, scalar_unit( + ), + chalk_ir::Scalar::Uint(i) => Layout::scalar( dl, - Primitive::Int( - match i { - UintTy::Usize => dl.ptr_sized_integer(), - UintTy::U8 => Integer::I8, - UintTy::U16 => Integer::I16, - UintTy::U32 => Integer::I32, - UintTy::U64 => Integer::I64, - UintTy::U128 => Integer::I128, - }, - false, + scalar_unit( + dl, + Primitive::Int( + match i { + UintTy::Usize => dl.ptr_sized_integer(), + UintTy::U8 => Integer::I8, + UintTy::U16 => Integer::I16, + UintTy::U32 => Integer::I32, + UintTy::U64 => Integer::I64, + UintTy::U128 => Integer::I128, + }, + false, + ), ), - )), - chalk_ir::Scalar::Float(f) => Layout::scalar(dl, scalar_unit( + ), + chalk_ir::Scalar::Float(f) => Layout::scalar( dl, - Primitive::Float(match f { - FloatTy::F16 => Float::F16, - FloatTy::F32 => Float::F32, - FloatTy::F64 => Float::F64, - FloatTy::F128 => Float::F128, - }), - )), + scalar_unit( + dl, + Primitive::Float(match f { + FloatTy::F16 => Float::F16, + FloatTy::F32 => Float::F32, + FloatTy::F64 => Float::F64, + FloatTy::F128 => Float::F128, + }), + ), + ), }, TyKind::Tuple(len, tys) => { let kind = if *len == 0 { StructKind::AlwaysSized } else { StructKind::MaybeUnsized };