From ab769ec6c1cabf938ee3fcc1022bfce076858b2a Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Wed, 5 Nov 2025 12:54:29 +0200 Subject: [PATCH 01/12] Micro-optimize rustdoc search index parsing --- src/librustdoc/html/render/search_index/encode.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/html/render/search_index/encode.rs b/src/librustdoc/html/render/search_index/encode.rs index d15e13a2d3742..a05c14374d1de 100644 --- a/src/librustdoc/html/render/search_index/encode.rs +++ b/src/librustdoc/html/render/search_index/encode.rs @@ -78,16 +78,9 @@ pub fn read_postings_from_string(postings: &mut Vec>, mut buf: &[u8]) { while let Some(&c) = buf.get(0) { if c < 0x3a { buf = &buf[1..]; - let mut slot = Vec::new(); - for _ in 0..c { - slot.push( - (buf[0] as u32) - | ((buf[1] as u32) << 8) - | ((buf[2] as u32) << 16) - | ((buf[3] as u32) << 24), - ); - buf = &buf[4..]; - } + let buf = buf.split_off(..usize::from(c) * size_of::()).unwrap(); + let (chunks, _) = buf.as_chunks(); + let slot = chunks.iter().copied().map(u32::from_le_bytes).collect(); postings.push(slot); } else { let (bitmap, consumed_bytes_len) = From 33da7285ace409b253612c1d37dcb54776adc7bf Mon Sep 17 00:00:00 2001 From: Pavel Grigorenko Date: Fri, 31 Oct 2025 15:36:55 +0300 Subject: [PATCH 02/12] `vec_recycle`: implementation --- library/alloc/src/lib.rs | 1 + library/alloc/src/vec/mod.rs | 88 +++++++++++++++++++++++++++++++++++- 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 666ae27fb8634..b61d95c3badf2 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -146,6 +146,7 @@ #![feature(std_internals)] #![feature(str_internals)] #![feature(temporary_niche_types)] +#![feature(transmutability)] #![feature(trivial_clone)] #![feature(trusted_fused)] #![feature(trusted_len)] diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 43a68ff203738..48241c124901a 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -82,7 +82,7 @@ use core::hash::{Hash, Hasher}; #[cfg(not(no_global_oom_handling))] use core::iter; use core::marker::PhantomData; -use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties}; +use core::mem::{self, Assume, ManuallyDrop, MaybeUninit, SizedTypeProperties, TransmuteFrom}; use core::ops::{self, Index, IndexMut, Range, RangeBounds}; use core::ptr::{self, NonNull}; use core::slice::{self, SliceIndex}; @@ -3243,6 +3243,92 @@ impl Vec { // - `cap / N` fits the size of the allocated memory after shrinking unsafe { Vec::from_raw_parts_in(ptr.cast(), len / N, cap / N, alloc) } } + + /// This clears out this `Vec` and recycles the allocation into a new `Vec`. + /// The item type of the resulting `Vec` needs to have the same size and + /// alignment as the item type of the original `Vec`. + /// + /// # Examples + /// + /// ``` + /// #![feature(vec_recycle, transmutability)] + /// let a: Vec = vec![0; 100]; + /// let capacity = a.capacity(); + /// let addr = a.as_ptr().addr(); + /// let b: Vec = a.recycle(); + /// assert_eq!(b.len(), 0); + /// assert_eq!(b.capacity(), capacity); + /// assert_eq!(b.as_ptr().addr(), addr); + /// ``` + /// + /// The `Recyclable` bound prevents this method from being called when `T` and `U` have different sizes; e.g.: + /// + /// ```compile_fail,E0277 + /// #![feature(vec_recycle, transmutability)] + /// let vec: Vec<[u8; 2]> = Vec::new(); + /// let _: Vec<[u8; 1]> = vec.recycle(); + /// ``` + /// ...or different alignments: + /// + /// ```compile_fail,E0277 + /// #![feature(vec_recycle, transmutability)] + /// let vec: Vec<[u16; 0]> = Vec::new(); + /// let _: Vec<[u8; 0]> = vec.recycle(); + /// ``` + /// + /// However, due to temporary implementation limitations of `Recyclable`, + /// this method is not yet callable when `T` or `U` are slices, trait objects, + /// or other exotic types; e.g.: + /// + /// ```compile_fail,E0277 + /// #![feature(vec_recycle, transmutability)] + /// # let inputs = ["a b c", "d e f"]; + /// # fn process(_: &[&str]) {} + /// let mut storage: Vec<&[&str]> = Vec::new(); + /// + /// for input in inputs { + /// let mut buffer: Vec<&str> = storage.recycle(); + /// buffer.extend(input.split(" ")); + /// process(&buffer); + /// storage = buffer.recycle(); + /// } + /// ``` + #[unstable(feature = "vec_recycle", issue = "148227")] + #[expect(private_bounds)] + pub fn recycle(mut self) -> Vec + where + U: Recyclable, + { + self.clear(); + const { + // FIXME(const-hack, 146097): compare `Layout`s + assert!(size_of::() == size_of::()); + assert!(align_of::() == align_of::()); + }; + let (ptr, length, capacity, alloc) = self.into_parts_with_alloc(); + debug_assert_eq!(length, 0); + // SAFETY: + // - `ptr` and `alloc` were just returned from `self.into_raw_parts_with_alloc()` + // - `T` & `U` have the same layout, so `capacity` does not need to be changed and we can safely use `alloc.dealloc` later + // - the original vector was cleared, so there is no problem with "transmuting" the stored values + unsafe { Vec::from_parts_in(ptr.cast::(), length, capacity, alloc) } + } +} + +/// Denotes that an allocation of `From` can be recycled into an allocation of `Self`. +/// +/// # Safety +/// +/// `Self` is `Recyclable` if `Layout::new::() == Layout::new::()`. +unsafe trait Recyclable: Sized {} + +#[unstable_feature_bound(transmutability)] +// SAFETY: enforced by `TransmuteFrom` +unsafe impl Recyclable for To +where + for<'a> &'a MaybeUninit: TransmuteFrom<&'a MaybeUninit, { Assume::SAFETY }>, + for<'a> &'a MaybeUninit: TransmuteFrom<&'a MaybeUninit, { Assume::SAFETY }>, +{ } impl Vec { From ac9bb13267fd120280ba18460e014491b5a4a352 Mon Sep 17 00:00:00 2001 From: Max Siling Date: Tue, 11 Nov 2025 19:34:29 +0300 Subject: [PATCH 03/12] Stabilize vec_into_raw_parts --- library/alloc/src/string.rs | 25 +++-------- library/alloc/src/vec/mod.rs | 66 ++++++------------------------ library/core/src/intrinsics/mod.rs | 8 +--- library/std/src/lib.rs | 1 - 4 files changed, 19 insertions(+), 81 deletions(-) diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 31743b0e35b24..4a2689e01ff17 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -265,18 +265,11 @@ use crate::vec::{self, Vec}; /// You can look at these with the [`as_ptr`], [`len`], and [`capacity`] /// methods: /// -// FIXME Update this when vec_into_raw_parts is stabilized /// ``` -/// use std::mem; -/// /// let story = String::from("Once upon a time..."); /// -/// // Prevent automatically dropping the String's data -/// let mut story = mem::ManuallyDrop::new(story); -/// -/// let ptr = story.as_mut_ptr(); -/// let len = story.len(); -/// let capacity = story.capacity(); +/// // Deconstruct the String into parts. +/// let (ptr, len, capacity) = story.into_raw_parts(); /// /// // story has nineteen bytes /// assert_eq!(19, len); @@ -932,7 +925,6 @@ impl String { /// # Examples /// /// ``` - /// #![feature(vec_into_raw_parts)] /// let s = String::from("hello"); /// /// let (ptr, len, cap) = s.into_raw_parts(); @@ -941,7 +933,7 @@ impl String { /// assert_eq!(rebuilt, "hello"); /// ``` #[must_use = "losing the pointer will leak memory"] - #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")] + #[stable(feature = "vec_into_raw_parts", since = "CURRENT_RUSTC_VERSION")] pub fn into_raw_parts(self) -> (*mut u8, usize, usize) { self.vec.into_raw_parts() } @@ -970,19 +962,12 @@ impl String { /// /// # Examples /// - // FIXME Update this when vec_into_raw_parts is stabilized /// ``` - /// use std::mem; - /// /// unsafe { /// let s = String::from("hello"); /// - /// // Prevent automatically dropping the String's data - /// let mut s = mem::ManuallyDrop::new(s); - /// - /// let ptr = s.as_mut_ptr(); - /// let len = s.len(); - /// let capacity = s.capacity(); + /// // Deconstruct the String into parts. + /// let (ptr, len, capacity) = s.into_raw_parts(); /// /// let s = String::from_raw_parts(ptr, len, capacity); /// diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 43a68ff203738..f8e14d7e54c0e 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -592,21 +592,13 @@ impl Vec { /// /// # Examples /// - // FIXME Update this when vec_into_raw_parts is stabilized /// ``` /// use std::ptr; - /// use std::mem; /// /// let v = vec![1, 2, 3]; /// - /// // Prevent running `v`'s destructor so we are in complete control - /// // of the allocation. - /// let mut v = mem::ManuallyDrop::new(v); - /// - /// // Pull out the various important pieces of information about `v` - /// let p = v.as_mut_ptr(); - /// let len = v.len(); - /// let cap = v.capacity(); + /// // Deconstruct the vector into parts. + /// let (p, len, cap) = v.into_raw_parts(); /// /// unsafe { /// // Overwrite memory with 4, 5, 6 @@ -700,23 +692,13 @@ impl Vec { /// /// # Examples /// - // FIXME Update this when vec_into_raw_parts is stabilized /// ``` /// #![feature(box_vec_non_null)] /// - /// use std::ptr::NonNull; - /// use std::mem; - /// /// let v = vec![1, 2, 3]; /// - /// // Prevent running `v`'s destructor so we are in complete control - /// // of the allocation. - /// let mut v = mem::ManuallyDrop::new(v); - /// - /// // Pull out the various important pieces of information about `v` - /// let p = unsafe { NonNull::new_unchecked(v.as_mut_ptr()) }; - /// let len = v.len(); - /// let cap = v.capacity(); + /// // Deconstruct the vector into parts. + /// let (p, len, cap) = v.into_parts(); /// /// unsafe { /// // Overwrite memory with 4, 5, 6 @@ -783,7 +765,6 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(vec_into_raw_parts)] /// let v: Vec = vec![-1, 0, 1]; /// /// let (ptr, len, cap) = v.into_raw_parts(); @@ -798,7 +779,7 @@ impl Vec { /// assert_eq!(rebuilt, [4294967295, 0, 1]); /// ``` #[must_use = "losing the pointer will leak memory"] - #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")] + #[stable(feature = "vec_into_raw_parts", since = "CURRENT_RUSTC_VERSION")] pub fn into_raw_parts(self) -> (*mut T, usize, usize) { let mut me = ManuallyDrop::new(self); (me.as_mut_ptr(), me.len(), me.capacity()) @@ -823,7 +804,7 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(vec_into_raw_parts, box_vec_non_null)] + /// #![feature(box_vec_non_null)] /// /// let v: Vec = vec![-1, 0, 1]; /// @@ -840,7 +821,6 @@ impl Vec { /// ``` #[must_use = "losing the pointer will leak memory"] #[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")] - // #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")] pub fn into_parts(self) -> (NonNull, usize, usize) { let (ptr, len, capacity) = self.into_raw_parts(); // SAFETY: A `Vec` always has a non-null pointer. @@ -996,29 +976,20 @@ impl Vec { /// /// # Examples /// - // FIXME Update this when vec_into_raw_parts is stabilized /// ``` /// #![feature(allocator_api)] /// /// use std::alloc::System; /// /// use std::ptr; - /// use std::mem; /// /// let mut v = Vec::with_capacity_in(3, System); /// v.push(1); /// v.push(2); /// v.push(3); /// - /// // Prevent running `v`'s destructor so we are in complete control - /// // of the allocation. - /// let mut v = mem::ManuallyDrop::new(v); - /// - /// // Pull out the various important pieces of information about `v` - /// let p = v.as_mut_ptr(); - /// let len = v.len(); - /// let cap = v.capacity(); - /// let alloc = v.allocator(); + /// // Deconstruct the vector into parts. + /// let (p, len, cap, alloc) = v.into_raw_parts_with_alloc(); /// /// unsafe { /// // Overwrite memory with 4, 5, 6 @@ -1116,29 +1087,18 @@ impl Vec { /// /// # Examples /// - // FIXME Update this when vec_into_raw_parts is stabilized /// ``` /// #![feature(allocator_api, box_vec_non_null)] /// /// use std::alloc::System; /// - /// use std::ptr::NonNull; - /// use std::mem; - /// /// let mut v = Vec::with_capacity_in(3, System); /// v.push(1); /// v.push(2); /// v.push(3); /// - /// // Prevent running `v`'s destructor so we are in complete control - /// // of the allocation. - /// let mut v = mem::ManuallyDrop::new(v); - /// - /// // Pull out the various important pieces of information about `v` - /// let p = unsafe { NonNull::new_unchecked(v.as_mut_ptr()) }; - /// let len = v.len(); - /// let cap = v.capacity(); - /// let alloc = v.allocator(); + /// // Deconstruct the vector into parts. + /// let (p, len, cap, alloc) = v.into_parts_with_alloc(); /// /// unsafe { /// // Overwrite memory with 4, 5, 6 @@ -1206,7 +1166,7 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(allocator_api, vec_into_raw_parts)] + /// #![feature(allocator_api)] /// /// use std::alloc::System; /// @@ -1228,7 +1188,6 @@ impl Vec { /// ``` #[must_use = "losing the pointer will leak memory"] #[unstable(feature = "allocator_api", issue = "32838")] - // #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")] pub fn into_raw_parts_with_alloc(self) -> (*mut T, usize, usize, A) { let mut me = ManuallyDrop::new(self); let len = me.len(); @@ -1256,7 +1215,7 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(allocator_api, vec_into_raw_parts, box_vec_non_null)] + /// #![feature(allocator_api, box_vec_non_null)] /// /// use std::alloc::System; /// @@ -1279,7 +1238,6 @@ impl Vec { #[must_use = "losing the pointer will leak memory"] #[unstable(feature = "allocator_api", issue = "32838")] // #[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")] - // #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")] pub fn into_parts_with_alloc(self) -> (NonNull, usize, usize, A) { let (ptr, len, capacity, alloc) = self.into_raw_parts_with_alloc(); // SAFETY: A `Vec` always has a non-null pointer. diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 6b13b4c4f56cc..82cb489ccf402 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -769,13 +769,9 @@ pub const fn forget(_: T); /// // in terms of converting the original inner type (`&i32`) to the new one (`Option<&i32>`), /// // this has all the same caveats. Besides the information provided above, also consult the /// // [`from_raw_parts`] documentation. +/// let (ptr, len, capacity) = v_clone.into_raw_parts(); /// let v_from_raw = unsafe { -// FIXME Update this when vec_into_raw_parts is stabilized -/// // Ensure the original vector is not dropped. -/// let mut v_clone = std::mem::ManuallyDrop::new(v_clone); -/// Vec::from_raw_parts(v_clone.as_mut_ptr() as *mut Option<&i32>, -/// v_clone.len(), -/// v_clone.capacity()) +/// Vec::from_raw_parts(ptr.cast::<*mut Option<&i32>>(), len, capacity) /// }; /// ``` /// diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 7b6cfbfe0f259..9099322708e0f 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -381,7 +381,6 @@ #![feature(try_reserve_kind)] #![feature(try_with_capacity)] #![feature(unique_rc_arc)] -#![feature(vec_into_raw_parts)] #![feature(wtf8_internals)] // tidy-alphabetical-end // From 7f98a16649b04d330054f05c2290009ef0d5683b Mon Sep 17 00:00:00 2001 From: Jamie Hill-Daniel Date: Tue, 11 Nov 2025 19:26:25 +0000 Subject: [PATCH 04/12] Bump library dependencies Updating crates.io index Locking 17 packages to latest compatible versions Updating addr2line v0.25.0 -> v0.25.1 Updating cfg-if v1.0.1 -> v1.0.4 Updating dlmalloc v0.2.10 -> v0.2.11 Updating gimli v0.32.0 -> v0.32.3 Updating vex-sdk v0.27.0 -> v0.27.1 (available: v0.28.0) Adding windows-link v0.2.1 Updating windows-sys v0.59.0 -> v0.60.2 Updating windows-targets v0.52.6 -> v0.53.5 Updating windows_aarch64_gnullvm v0.52.6 -> v0.53.1 Updating windows_aarch64_msvc v0.52.6 -> v0.53.1 Updating windows_i686_gnu v0.52.6 -> v0.53.1 Updating windows_i686_gnullvm v0.52.6 -> v0.53.1 Updating windows_i686_msvc v0.52.6 -> v0.53.1 Updating windows_x86_64_gnu v0.52.6 -> v0.53.1 Updating windows_x86_64_gnullvm v0.52.6 -> v0.53.1 Updating windows_x86_64_msvc v0.52.6 -> v0.53.1 Updating wit-bindgen v0.45.0 -> v0.45.1 --- library/Cargo.lock | 73 +++++++++++++++++++++----------------- src/tools/tidy/src/deps.rs | 1 + 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/library/Cargo.lock b/library/Cargo.lock index f06f57799c2fc..b062b505cb248 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -4,9 +4,9 @@ version = 4 [[package]] name = "addr2line" -version = "0.25.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9acbfca36652500c911ddb767ed433e3ed99b032b5d935be73c6923662db1d43" +checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" dependencies = [ "gimli", "rustc-std-workspace-alloc", @@ -49,9 +49,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" dependencies = [ "rustc-std-workspace-core", ] @@ -78,9 +78,9 @@ dependencies = [ [[package]] name = "dlmalloc" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa3a2dbee57b69fbb5dbe852fa9c0925697fb0c7fbcb1593e90e5ffaedf13d51" +checksum = "06cdfe340b16dd990c54cce79743613fa09fbb16774f33a77c9fd196f8f3fa30" dependencies = [ "cfg-if", "libc", @@ -109,9 +109,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.32.0" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93563d740bc9ef04104f9ed6f86f1e3275c2cdafb95664e26584b9ca807a8ffe" +checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" dependencies = [ "rustc-std-workspace-alloc", "rustc-std-workspace-core", @@ -393,9 +393,9 @@ dependencies = [ [[package]] name = "vex-sdk" -version = "0.27.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89f74fce61d7a7ba1589da9634c6305a72befb7cc9150c1f872d87d8060f32b9" +checksum = "79e5fe15afde1305478b35e2cb717fff59f485428534cf49cfdbfa4723379bf6" dependencies = [ "rustc-std-workspace-core", ] @@ -421,13 +421,19 @@ dependencies = [ "wit-bindgen", ] +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-sys" -version = "0.59.0" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.52.6", + "windows-targets 0.53.5", ] [[package]] @@ -436,10 +442,11 @@ version = "0.0.0" [[package]] name = "windows-targets" -version = "0.52.6" +version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ + "windows-link", "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", @@ -452,57 +459,57 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.6" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" [[package]] name = "windows_aarch64_msvc" -version = "0.52.6" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" [[package]] name = "windows_i686_gnu" -version = "0.52.6" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" [[package]] name = "windows_i686_gnullvm" -version = "0.52.6" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" [[package]] name = "windows_i686_msvc" -version = "0.52.6" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" [[package]] name = "windows_x86_64_gnu" -version = "0.52.6" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.6" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" [[package]] name = "windows_x86_64_msvc" -version = "0.52.6" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "wit-bindgen" -version = "0.45.0" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052283831dbae3d879dc7f51f3d92703a316ca49f91540417d38591826127814" +checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36" dependencies = [ "rustc-std-workspace-alloc", "rustc-std-workspace-core", diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index c8bd215a1cb42..93d38d929c6d0 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -530,6 +530,7 @@ const PERMITTED_STDLIB_DEPENDENCIES: &[&str] = &[ "unwinding", "vex-sdk", "wasi", + "windows-link", "windows-sys", "windows-targets", "windows_aarch64_gnullvm", From 7b09e1c82b35ca564e3a6dce5e06271733571646 Mon Sep 17 00:00:00 2001 From: Eric Seppanen Date: Tue, 11 Nov 2025 11:46:08 -0800 Subject: [PATCH 05/12] improve primitive reference PartialEq docs This sentence was unnecessarily complex; try to simplify it. --- library/core/src/primitive_docs.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index 1c824e336bed7..5988e477973f6 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -1531,9 +1531,8 @@ mod prim_usize {} /// `&mut T` references can be freely coerced into `&T` references with the same referent type, and /// references with longer lifetimes can be freely coerced into references with shorter ones. /// -/// Reference equality by address, instead of comparing the values pointed to, is accomplished via -/// implicit reference-pointer coercion and raw pointer equality via [`ptr::eq`], while -/// [`PartialEq`] compares values. +/// [`PartialEq`] will compare referenced values. It is possible to compare the reference address +/// using reference-pointer coercion and raw pointer equality via [`ptr::eq`]. /// /// ``` /// use std::ptr; From cac1f99d6dce2ffc1cfdf24be9a30e4adeb26e9d Mon Sep 17 00:00:00 2001 From: Eric Seppanen Date: Tue, 11 Nov 2025 11:46:08 -0800 Subject: [PATCH 06/12] fix typo in primitive reference docs --- library/core/src/primitive_docs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index 5988e477973f6..15ba72bccaa9b 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -1647,7 +1647,7 @@ mod prim_usize {} /// For the other direction, things are more complicated: when unsafe code passes arguments /// to safe functions or returns values from safe functions, they generally must *at least* /// not violate these invariants. The full requirements are stronger, as the reference generally -/// must point to data that is safe to use at type `T`. +/// must point to data that is safe to use as type `T`. /// /// It is not decided yet whether unsafe code may violate these invariants temporarily on internal /// data. As a consequence, unsafe code which violates these invariants temporarily on internal data From eef09cfb7d834d553511ced2015c9da8c0d1721d Mon Sep 17 00:00:00 2001 From: Zhongyao Chen Date: Wed, 12 Nov 2025 17:42:21 +0800 Subject: [PATCH 07/12] tests: Fix overflow-checks test for RISC-V target The overflow-checks codegen test was failing on riscv64gc target because the FileCheck pattern did not account for ABI extension attributes. RISC-V LP64 ABI requires integer types smaller than XLEN (64-bit) to be zero-extended or sign-extended to register width. For u8 parameters, RISC-V generates: i8 noundef zeroext %a, i8 noundef zeroext %b While x86_64 and aarch64 generate: i8 noundef %a, i8 noundef %b The original CHECK pattern only matched the format without the `zeroext` attribute, causing test failures on RISC-V. This patch makes the zeroext attribute optional in the FileCheck pattern using `{{( zeroext)?}}`, allowing the test to pass on architectures that add ABI extension attributes (e.g., RISC-V). Test results before fix: - x86_64-unknown-linux-gnu: 3 passed - aarch64-unknown-linux-gnu: 3 passed - riscv64gc-unknown-linux-gnu: 1 passed, 2 failed Test results after fix: - x86_64-unknown-linux-gnu: 3 passed - aarch64-unknown-linux-gnu: 3 passed - riscv64gc-unknown-linux-gnu: 3 passed --- tests/codegen-llvm/overflow-checks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codegen-llvm/overflow-checks.rs b/tests/codegen-llvm/overflow-checks.rs index c8b10df507b0f..3a48e6b76243b 100644 --- a/tests/codegen-llvm/overflow-checks.rs +++ b/tests/codegen-llvm/overflow-checks.rs @@ -18,7 +18,7 @@ extern crate overflow_checks_add; // CHECK-LABEL: @add( #[no_mangle] pub unsafe fn add(a: u8, b: u8) -> u8 { - // CHECK: i8 noundef %a, i8 noundef %b + // CHECK: i8 noundef{{( zeroext)?}} %a, i8 noundef{{( zeroext)?}} %b // CHECK: add i8 %b, %a // DEBUG: icmp ult i8 [[zero:[^,]+]], %a // DEBUG: call core::num::overflow_panic::add From 98cd15709d68262367c72889e5d04aabda1eef61 Mon Sep 17 00:00:00 2001 From: Zhongyao Chen Date: Thu, 13 Nov 2025 10:28:38 +0800 Subject: [PATCH 08/12] Add riscv64a23-unknown-linux-gnu to build-manifest TARGETS This enables rustup distribution of the rust-std component for the riscv64a23-unknown-linux-gnu target, allowing users to install it via `rustup target add riscv64a23-unknown-linux-gnu`. --- src/tools/build-manifest/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 9bae8b241a941..3f19e1128df9d 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -153,6 +153,7 @@ static TARGETS: &[&str] = &[ "riscv32imafc-unknown-none-elf", "riscv32gc-unknown-linux-gnu", "riscv64imac-unknown-none-elf", + "riscv64a23-unknown-linux-gnu", "riscv64gc-unknown-hermit", "riscv64gc-unknown-none-elf", "riscv64gc-unknown-linux-gnu", From 583d5de732c529be93409b71c38c144a6a41bf2f Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Sat, 15 Nov 2025 00:17:14 +0100 Subject: [PATCH 09/12] re-enable wasm abi test --- tests/ui/abi/compatibility.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index 906f372dd4411..350b98191cf57 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -40,10 +40,9 @@ //@ revisions: loongarch64 //@[loongarch64] compile-flags: --target loongarch64-unknown-linux-gnu //@[loongarch64] needs-llvm-components: loongarch -//FIXME: wasm is disabled due to . -//FIXME @ revisions: wasm -//FIXME @[wasm] compile-flags: --target wasm32-unknown-unknown -//FIXME @[wasm] needs-llvm-components: webassembly +//@ revisions: wasm +//@[wasm] compile-flags: --target wasm32-unknown-unknown +//@[wasm] needs-llvm-components: webassembly //@ revisions: wasip1 //@[wasip1] compile-flags: --target wasm32-wasip1 //@[wasip1] needs-llvm-components: webassembly From 41712680c0c63f3d228d3acbfa94aa263dedfadc Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 15 Nov 2025 07:28:36 +0200 Subject: [PATCH 10/12] runtest.rs: remove redundant check The check is already done in enclosing code --- src/tools/compiletest/src/runtest.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 6f9fdd52fc083..8527f7e8128f4 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1635,8 +1635,7 @@ impl<'test> TestCx<'test> { // executed and that don't specify their own optimization levels. // Note: aux libs don't have a pass-mode, so they won't get optimized // unless compile-flags are set in the aux file. - if self.config.optimize_tests - && self.props.pass_mode(&self.config) == Some(PassMode::Run) + if self.props.pass_mode(&self.config) == Some(PassMode::Run) && !self .props .compile_flags From e10a7db4d48d89087239c27796aed7411db64a2f Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 15 Nov 2025 01:28:54 -0800 Subject: [PATCH 11/12] Add another *ExprWithBlock* test for `try` blocks --- tests/ui/try-block/try-block-as-statement.rs | 24 +++++++++++++++++++ .../try-block/try-block-as-statement.stderr | 16 +++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/ui/try-block/try-block-as-statement.rs create mode 100644 tests/ui/try-block/try-block-as-statement.stderr diff --git a/tests/ui/try-block/try-block-as-statement.rs b/tests/ui/try-block/try-block-as-statement.rs new file mode 100644 index 0000000000000..37469151ceb26 --- /dev/null +++ b/tests/ui/try-block/try-block-as-statement.rs @@ -0,0 +1,24 @@ +//@ check-fail +//@ edition: 2018 + +#![feature(try_blocks)] +#![crate_type = "lib"] + +// fine because the `;` discards the value +fn foo(a: &str, b: &str) -> i32 { + try { + let foo = std::fs::read_to_string(a)?; + std::fs::write(b, foo); + }; + 4 + 10 +} + +// parses without the semicolon, but gives a type error +fn bar(a: &str, b: &str) -> i32 { + try { + let foo = std::fs::read_to_string(a)?; + //~^ ERROR mismatched types + std::fs::write(b, foo); + } + 4 + 10 +} diff --git a/tests/ui/try-block/try-block-as-statement.stderr b/tests/ui/try-block/try-block-as-statement.stderr new file mode 100644 index 0000000000000..e9b23daec0375 --- /dev/null +++ b/tests/ui/try-block/try-block-as-statement.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/try-block-as-statement.rs:19:19 + | +LL | let foo = std::fs::read_to_string(a)?; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Result<_, Error>` + | + = note: expected unit type `()` + found enum `Result<_, std::io::Error>` +help: consider using `Result::expect` to unwrap the `Result<_, std::io::Error>` value, panicking if the value is a `Result::Err` + | +LL | let foo = std::fs::read_to_string(a)?.expect("REASON"); + | +++++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. From 463c6cea684c4a454917cc36d421f9bef87925c7 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Sat, 15 Nov 2025 13:53:51 -0700 Subject: [PATCH 12/12] chore: Update annotate-snippets to 0.12.9 --- Cargo.lock | 6 +++--- compiler/rustc_errors/Cargo.toml | 2 +- tests/ui/lifetimes/borrowck-let-suggestion.stderr | 2 +- tests/ui/test-attrs/inaccessible-test-modules.stderr | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa80fedbb44a8..9350112939bd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "annotate-snippets" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "025c7edcdffa4ccc5c0905f472a0ae3759378cfbef88ef518a3575e19ae3aebd" +checksum = "a44baf24dd94e781f74dfe67ffee75a09a57971ddf0f615a178b4f6d404b48ff" dependencies = [ "anstyle", "unicode-width 0.2.2", @@ -3766,7 +3766,7 @@ dependencies = [ name = "rustc_errors" version = "0.0.0" dependencies = [ - "annotate-snippets 0.12.8", + "annotate-snippets 0.12.9", "anstream", "anstyle", "derive_setters", diff --git a/compiler/rustc_errors/Cargo.toml b/compiler/rustc_errors/Cargo.toml index 6606092e421eb..b3f76732a602c 100644 --- a/compiler/rustc_errors/Cargo.toml +++ b/compiler/rustc_errors/Cargo.toml @@ -5,7 +5,7 @@ edition = "2024" [dependencies] # tidy-alphabetical-start -annotate-snippets = "0.12.8" +annotate-snippets = "0.12.9" anstream = "0.6.20" anstyle = "1.0.13" derive_setters = "0.1.6" diff --git a/tests/ui/lifetimes/borrowck-let-suggestion.stderr b/tests/ui/lifetimes/borrowck-let-suggestion.stderr index 9020ee22f9bd8..4703d7f10dc28 100644 --- a/tests/ui/lifetimes/borrowck-let-suggestion.stderr +++ b/tests/ui/lifetimes/borrowck-let-suggestion.stderr @@ -13,7 +13,7 @@ LL | x.use_mut(); help: consider consuming the `Vec` when turning it into an `Iterator` | LL | let mut x = vec![1].into_iter(); - | +++++ + | +++++ help: consider using a `let` binding to create a longer lived value | LL ~ let binding = vec![1]; diff --git a/tests/ui/test-attrs/inaccessible-test-modules.stderr b/tests/ui/test-attrs/inaccessible-test-modules.stderr index c66dc0d0fc26c..dfb6985730af5 100644 --- a/tests/ui/test-attrs/inaccessible-test-modules.stderr +++ b/tests/ui/test-attrs/inaccessible-test-modules.stderr @@ -13,7 +13,7 @@ LL | use test as y; help: consider importing this module instead | LL | use test::test as y; - | ++++++ + | ++++++ error: aborting due to 2 previous errors