From 749065a824a64da0807d27a122598204393f505d Mon Sep 17 00:00:00 2001 From: Pavel Grigorenko Date: Sun, 22 Dec 2024 14:47:21 +0300 Subject: [PATCH 1/9] Stabilize `hash_extract_if` --- library/std/src/collections/hash/map.rs | 13 +++++-------- library/std/src/collections/hash/set.rs | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index 109bc3946346f..0e25c1bfe0c90 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -659,7 +659,6 @@ impl HashMap { /// Splitting a map into even and odd keys, reusing the original map: /// /// ``` - /// #![feature(hash_extract_if)] /// use std::collections::HashMap; /// /// let mut map: HashMap = (0..8).map(|x| (x, x)).collect(); @@ -675,7 +674,7 @@ impl HashMap { /// ``` #[inline] #[rustc_lint_query_instability] - #[unstable(feature = "hash_extract_if", issue = "59618")] + #[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] pub fn extract_if(&mut self, pred: F) -> ExtractIf<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool, @@ -1718,8 +1717,6 @@ impl<'a, K, V> Drain<'a, K, V> { /// # Example /// /// ``` -/// #![feature(hash_extract_if)] -/// /// use std::collections::HashMap; /// /// let mut map = HashMap::from([ @@ -1727,7 +1724,7 @@ impl<'a, K, V> Drain<'a, K, V> { /// ]); /// let iter = map.extract_if(|_k, v| *v % 2 == 0); /// ``` -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct ExtractIf<'a, K, V, F> where @@ -2742,7 +2739,7 @@ where } } -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl Iterator for ExtractIf<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool, @@ -2759,10 +2756,10 @@ where } } -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl FusedIterator for ExtractIf<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool {} -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl<'a, K, V, F> fmt::Debug for ExtractIf<'a, K, V, F> where F: FnMut(&K, &mut V) -> bool, diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 4c81aaff45886..e7b04af11985a 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -293,7 +293,6 @@ impl HashSet { /// Splitting a set into even and odd values, reusing the original set: /// /// ``` - /// #![feature(hash_extract_if)] /// use std::collections::HashSet; /// /// let mut set: HashSet = (0..8).collect(); @@ -309,7 +308,7 @@ impl HashSet { /// ``` #[inline] #[rustc_lint_query_instability] - #[unstable(feature = "hash_extract_if", issue = "59618")] + #[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] pub fn extract_if(&mut self, pred: F) -> ExtractIf<'_, T, F> where F: FnMut(&T) -> bool, @@ -1383,15 +1382,13 @@ pub struct Drain<'a, K: 'a> { /// # Examples /// /// ``` -/// #![feature(hash_extract_if)] -/// /// use std::collections::HashSet; /// /// let mut a = HashSet::from([1, 2, 3]); /// /// let mut extract_ifed = a.extract_if(|v| v % 2 == 0); /// ``` -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] pub struct ExtractIf<'a, K, F> where F: FnMut(&K) -> bool, @@ -1674,7 +1671,7 @@ impl fmt::Debug for Drain<'_, K> { } } -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl Iterator for ExtractIf<'_, K, F> where F: FnMut(&K) -> bool, @@ -1691,10 +1688,10 @@ where } } -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl FusedIterator for ExtractIf<'_, K, F> where F: FnMut(&K) -> bool {} -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl<'a, K, F> fmt::Debug for ExtractIf<'a, K, F> where F: FnMut(&K) -> bool, From 65a5d8bf6c5caf5b7084cdc70ce184f3d505638d Mon Sep 17 00:00:00 2001 From: Robert Bastian <4706271+robertbastian@users.noreply.github.com> Date: Sun, 9 Feb 2025 17:08:39 +0100 Subject: [PATCH 2/9] Update string.rs --- library/alloc/src/string.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index b29f740ef0f2a..a222ce040a4a6 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -966,11 +966,8 @@ impl String { /// This is highly unsafe, due to the number of invariants that aren't /// checked: /// - /// * The memory at `buf` needs to have been previously allocated by the - /// same allocator the standard library uses, with a required alignment of exactly 1. - /// * `length` needs to be less than or equal to `capacity`. - /// * `capacity` needs to be the correct value. - /// * The first `length` bytes at `buf` need to be valid UTF-8. + /// * all safety requirements for [`Vec::::from_raw_parts`] + /// * all safety requirements for [`String::from_utf8_unchecked`] /// /// Violating these may cause problems like corrupting the allocator's /// internal data structures. For example, it is normally **not** safe to From 98b0f050cf61f86cd39babe1fa4b33808fdc0770 Mon Sep 17 00:00:00 2001 From: Thalia Archibald Date: Fri, 7 Feb 2025 17:40:15 -0800 Subject: [PATCH 3/9] Implement read_buf for zkVM stdin For the zkVM, even when a guest buffer is uninitialized, from the host's perspective it is just a normal piece of memory which was initialized before letting the guest write into it. This makes `sys_read` safe to use with an uninitialized buffer. See https://github.com/risc0/risc0/issues/2853. --- library/std/src/sys/pal/zkvm/stdio.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/pal/zkvm/stdio.rs b/library/std/src/sys/pal/zkvm/stdio.rs index 5f1d06dd1d78d..0bcb54744b0b6 100644 --- a/library/std/src/sys/pal/zkvm/stdio.rs +++ b/library/std/src/sys/pal/zkvm/stdio.rs @@ -1,6 +1,6 @@ use super::abi; use super::abi::fileno; -use crate::io; +use crate::io::{self, BorrowedCursor}; pub struct Stdin; pub struct Stdout; @@ -16,6 +16,14 @@ impl io::Read for Stdin { fn read(&mut self, buf: &mut [u8]) -> io::Result { Ok(unsafe { abi::sys_read(fileno::STDIN, buf.as_mut_ptr(), buf.len()) }) } + + fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> { + unsafe { + let n = abi::sys_read(fileno::STDIN, buf.as_mut().as_mut_ptr().cast(), buf.capacity()); + buf.advance_unchecked(n); + } + Ok(()) + } } impl Stdout { From da7210b17fff5b3b3636f7ab7d3ffc400cbb5fbf Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Thu, 23 Jan 2025 15:17:11 +0100 Subject: [PATCH 4/9] Explain how Vec::with_capacity is faithful Co-authored-by: Jubilee and jmaargh --- library/alloc/src/vec/mod.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index cd2afd7a47319..816ec3cc4a12e 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -355,11 +355,20 @@ mod spec_extend; /// and it may prove desirable to use a non-constant growth factor. Whatever /// strategy is used will of course guarantee *O*(1) amortized [`push`]. /// -/// `vec![x; n]`, `vec![a, b, c, d]`, and -/// [`Vec::with_capacity(n)`][`Vec::with_capacity`], will all produce a `Vec` -/// with at least the requested capacity. If [len] == [capacity], -/// (as is the case for the [`vec!`] macro), then a `Vec` can be converted to -/// and from a [`Box<[T]>`][owned slice] without reallocating or moving the elements. +/// It is guaranteed, in order to respect the intentions of the programmer, that +/// all of `vec![e_1, e_2, ..., e_n]`, `vec![x; n]`, and [`Vec::with_capacity(n)`] produce a `Vec` +/// that requests an allocation of the exact size needed for precisely `n` elements from the allocator, +/// and no other size (such as, for example: a size rounded up to the nearest power of 2). +/// The allocator will return an allocation that is at least as large as requested, but it may be larger. +/// +/// It is guaranteed that the [`Vec::capacity`] method returns a value that is at least the requested capacity +/// and not more than the allocated capacity. +/// +/// The method [`Vec::shrink_to_fit`] will attempt to discard excess capacity an allocator has given to a `Vec`. +/// If [len] == [capacity], then a `Vec` can be converted +/// to and from a [`Box<[T]>`][owned slice] without reallocating or moving the elements. +/// `Vec` exploits this fact as much as reasonable when implementing common conversions +/// such as [`into_boxed_slice`]. /// /// `Vec` will not specifically overwrite any data that is removed from it, /// but also won't specifically preserve it. Its uninitialized memory is @@ -383,14 +392,17 @@ mod spec_extend; /// [`shrink_to`]: Vec::shrink_to /// [capacity]: Vec::capacity /// [`capacity`]: Vec::capacity +/// [`Vec::capacity`]: Vec::capacity /// [mem::size_of::\]: core::mem::size_of /// [len]: Vec::len /// [`len`]: Vec::len /// [`push`]: Vec::push /// [`insert`]: Vec::insert /// [`reserve`]: Vec::reserve +/// [`Vec::with_capacity(n)`]: Vec::with_capacity /// [`MaybeUninit`]: core::mem::MaybeUninit /// [owned slice]: Box +/// [`into_boxed_slice`]: Vec::into_boxed_slice #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "Vec")] #[rustc_insignificant_dtor] From c39f33baae94665d69a45d45a00d0dc028c80cc9 Mon Sep 17 00:00:00 2001 From: bendn Date: Sun, 16 Feb 2025 12:38:11 +0700 Subject: [PATCH 5/9] stabilize extract_if --- compiler/rustc_errors/src/lib.rs | 1 - compiler/rustc_lint/src/lib.rs | 1 - compiler/rustc_metadata/src/lib.rs | 1 - compiler/rustc_middle/src/lib.rs | 1 - compiler/rustc_resolve/src/lib.rs | 1 - compiler/rustc_trait_selection/src/lib.rs | 1 - library/alloc/src/collections/linked_list.rs | 9 ++++----- library/alloc/src/vec/extract_if.rs | 8 +++----- library/alloc/src/vec/mod.rs | 6 ++---- library/alloc/tests/lib.rs | 1 - src/tools/miri/src/lib.rs | 1 - 11 files changed, 9 insertions(+), 22 deletions(-) diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index ceed0cd94fc91..f2b133f56773b 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -15,7 +15,6 @@ #![feature(box_into_inner)] #![feature(box_patterns)] #![feature(error_reporter)] -#![feature(extract_if)] #![feature(if_let_guard)] #![feature(let_chains)] #![feature(negative_impls)] diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 044a613dad62b..70d3f73323a02 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -27,7 +27,6 @@ #![feature(array_windows)] #![feature(assert_matches)] #![feature(box_patterns)] -#![feature(extract_if)] #![feature(if_let_guard)] #![feature(iter_order_by)] #![feature(let_chains)] diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index b817b4cb7b83c..ebcc0efd5a67a 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -5,7 +5,6 @@ #![feature(coroutines)] #![feature(decl_macro)] #![feature(error_iter)] -#![feature(extract_if)] #![feature(file_buffered)] #![feature(if_let_guard)] #![feature(iter_from_coroutine)] diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 95128a5d903bb..8c8fbae130a29 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -45,7 +45,6 @@ #![feature(decl_macro)] #![feature(discriminant_kind)] #![feature(extern_types)] -#![feature(extract_if)] #![feature(file_buffered)] #![feature(if_let_guard)] #![feature(intra_doc_pointers)] diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index eb4ac6ce77c9c..ea48d0cad7456 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -15,7 +15,6 @@ #![doc(rust_logo)] #![feature(assert_matches)] #![feature(box_patterns)] -#![feature(extract_if)] #![feature(if_let_guard)] #![feature(iter_intersperse)] #![feature(let_chains)] diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 1af383e9200d0..b235d0da83cca 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -20,7 +20,6 @@ #![feature(associated_type_defaults)] #![feature(box_patterns)] #![feature(cfg_version)] -#![feature(extract_if)] #![feature(if_let_guard)] #![feature(iter_intersperse)] #![feature(iterator_try_reduce)] diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index 13168b7a39fe4..3183268b4b32e 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -1140,7 +1140,6 @@ impl LinkedList { /// Splitting a list into evens and odds, reusing the original list: /// /// ``` - /// #![feature(extract_if)] /// use std::collections::LinkedList; /// /// let mut numbers: LinkedList = LinkedList::new(); @@ -1152,7 +1151,7 @@ impl LinkedList { /// assert_eq!(evens.into_iter().collect::>(), vec![2, 4, 6, 8, 14]); /// assert_eq!(odds.into_iter().collect::>(), vec![1, 3, 5, 9, 11, 13, 15]); /// ``` - #[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] + #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] pub fn extract_if(&mut self, filter: F) -> ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool, @@ -1932,7 +1931,7 @@ impl<'a, T, A: Allocator> CursorMut<'a, T, A> { } /// An iterator produced by calling `extract_if` on LinkedList. -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct ExtractIf< 'a, @@ -1947,7 +1946,7 @@ pub struct ExtractIf< old_len: usize, } -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] impl Iterator for ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool, @@ -1976,7 +1975,7 @@ where } } -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] impl fmt::Debug for ExtractIf<'_, T, F> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("ExtractIf").field(&self.list).finish() diff --git a/library/alloc/src/vec/extract_if.rs b/library/alloc/src/vec/extract_if.rs index 4db13981596bc..be869553ef4e1 100644 --- a/library/alloc/src/vec/extract_if.rs +++ b/library/alloc/src/vec/extract_if.rs @@ -12,12 +12,10 @@ use crate::alloc::{Allocator, Global}; /// # Example /// /// ``` -/// #![feature(extract_if)] -/// /// let mut v = vec![0, 1, 2]; /// let iter: std::vec::ExtractIf<'_, _, _> = v.extract_if(.., |x| *x % 2 == 0); /// ``` -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] #[derive(Debug)] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct ExtractIf< @@ -59,7 +57,7 @@ impl<'a, T, F, A: Allocator> ExtractIf<'a, T, F, A> { } } -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] impl Iterator for ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool, @@ -95,7 +93,7 @@ where } } -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] impl Drop for ExtractIf<'_, T, F, A> { fn drop(&mut self) { unsafe { diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 7d02a15ed7a51..9a9e3b3181444 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -66,7 +66,7 @@ use core::ptr::{self, NonNull}; use core::slice::{self, SliceIndex}; use core::{fmt, intrinsics}; -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] pub use self::extract_if::ExtractIf; use crate::alloc::{Allocator, Global}; use crate::borrow::{Cow, ToOwned}; @@ -3684,7 +3684,6 @@ impl Vec { /// Splitting an array into evens and odds, reusing the original allocation: /// /// ``` - /// #![feature(extract_if)] /// let mut numbers = vec![1, 2, 3, 4, 5, 6, 8, 9, 11, 13, 14, 15]; /// /// let evens = numbers.extract_if(.., |x| *x % 2 == 0).collect::>(); @@ -3697,13 +3696,12 @@ impl Vec { /// Using the range argument to only process a part of the vector: /// /// ``` - /// #![feature(extract_if)] /// let mut items = vec![0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 2]; /// let ones = items.extract_if(7.., |x| *x == 1).collect::>(); /// assert_eq!(items, vec![0, 0, 0, 0, 0, 0, 0, 2, 2, 2]); /// assert_eq!(ones.len(), 3); /// ``` - #[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] + #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] pub fn extract_if(&mut self, range: R, filter: F) -> ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool, diff --git a/library/alloc/tests/lib.rs b/library/alloc/tests/lib.rs index f95be6a6df0b3..c83c978b3c077 100644 --- a/library/alloc/tests/lib.rs +++ b/library/alloc/tests/lib.rs @@ -7,7 +7,6 @@ #![feature(cow_is_borrowed)] #![feature(core_intrinsics)] #![feature(downcast_unchecked)] -#![feature(extract_if)] #![feature(exact_size_is_empty)] #![feature(hashmap_internals)] #![feature(linked_list_cursors)] diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 3b89f4a20d79f..016f0673ed763 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -16,7 +16,6 @@ #![feature(unqualified_local_imports)] #![feature(derive_coerce_pointee)] #![feature(arbitrary_self_types)] -#![feature(extract_if)] // Configure clippy and other lints #![allow( clippy::collapsible_else_if, From bf3ed81c206c7b4eb1b491e8c0d9545efa2e14a0 Mon Sep 17 00:00:00 2001 From: Waffle Lapkin Date: Fri, 7 Feb 2025 04:22:52 +0100 Subject: [PATCH 6/9] Stabilize `core::str::from_utf8_mut` --- library/alloc/tests/lib.rs | 1 - library/core/src/str/converts.rs | 2 +- library/core/src/str/mod.rs | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/library/alloc/tests/lib.rs b/library/alloc/tests/lib.rs index f95be6a6df0b3..e003625f2540e 100644 --- a/library/alloc/tests/lib.rs +++ b/library/alloc/tests/lib.rs @@ -29,7 +29,6 @@ #![feature(string_remove_matches)] #![feature(const_btree_len)] #![feature(const_trait_impl)] -#![feature(const_str_from_utf8)] #![feature(panic_update_hook)] #![feature(pointer_is_aligned_to)] #![feature(test)] diff --git a/library/core/src/str/converts.rs b/library/core/src/str/converts.rs index de68f80aa0c8e..1276d9014f0ef 100644 --- a/library/core/src/str/converts.rs +++ b/library/core/src/str/converts.rs @@ -126,7 +126,7 @@ pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> { /// See the docs for [`Utf8Error`] for more details on the kinds of /// errors that can be returned. #[stable(feature = "str_mut_extras", since = "1.20.0")] -#[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")] +#[rustc_const_stable(feature = "const_str_from_utf8", since = "CURRENT_RUSTC_VERSION")] #[rustc_diagnostic_item = "str_from_utf8_mut"] pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> { // FIXME(const-hack): This should use `?` again, once it's `const` diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 4754d18b06eac..7273af80726b4 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -265,7 +265,7 @@ impl str { /// See the docs for [`Utf8Error`] for more details on the kinds of /// errors that can be returned. #[stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")] + #[rustc_const_stable(feature = "const_str_from_utf8", since = "CURRENT_RUSTC_VERSION")] #[rustc_diagnostic_item = "str_inherent_from_utf8_mut"] pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> { converts::from_utf8_mut(v) From 097d64205a67d6582dc28e85cdca8a9f53c310e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 23 Feb 2025 19:11:37 +0100 Subject: [PATCH 7/9] configure.py: don't instruct user to run nonexistent program $ ./configure configure: processing command line configure: configure: build.configure-args := [] configure: profile := dist configure: configure: writing `config.toml` in current directory configure: configure: run `python /mnt/filling/store/nabijaczleweli/code/rust/x.py --help` This is naturally not valid since I don't have a "python" executable (and this will hopefully become more and more true as Python 2 dies out). ./configure knows this since it does try python3 "$@", then python2.7 &c. After, this now says configure: run `python3 /mnt/filling/store/nabijaczleweli/code/rust/x.py --help` which is possible, and corresponds to the interpreter actually running. --- src/bootstrap/configure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index ac971a64d7c22..e3f58d97cbc4c 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -776,6 +776,6 @@ def quit_if_file_exists(file): f.write(contents) p("") - p("run `python {}/x.py --help`".format(rust_dir)) + p("run `{} {}/x.py --help`".format(os.path.basename(sys.executable), rust_dir)) if "GITHUB_ACTIONS" in os.environ: print("::endgroup::") From 68543abb45f446e29fceec5d62045acc02e40480 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 24 Feb 2025 08:52:33 +0100 Subject: [PATCH 8/9] remove some unnecessary rustc_const_unstable --- library/core/src/mem/maybe_uninit.rs | 3 --- library/core/src/slice/mod.rs | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index edc39f8f28cf5..786a5a5b6bba4 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -1041,7 +1041,6 @@ impl MaybeUninit { /// Deprecated version of [`slice::assume_init_ref`]. #[unstable(feature = "maybe_uninit_slice", issue = "63569")] - #[rustc_const_unstable(feature = "maybe_uninit_slice", issue = "63569")] #[deprecated( note = "replaced by inherent assume_init_ref method; will eventually be removed", since = "1.83.0" @@ -1053,7 +1052,6 @@ impl MaybeUninit { /// Deprecated version of [`slice::assume_init_mut`]. #[unstable(feature = "maybe_uninit_slice", issue = "63569")] - #[rustc_const_unstable(feature = "maybe_uninit_slice", issue = "63569")] #[deprecated( note = "replaced by inherent assume_init_mut method; will eventually be removed", since = "1.83.0" @@ -1326,7 +1324,6 @@ impl [MaybeUninit] { /// /// [`write_clone_of_slice`]: slice::write_clone_of_slice #[unstable(feature = "maybe_uninit_write_slice", issue = "79995")] - #[rustc_const_unstable(feature = "maybe_uninit_write_slice", issue = "79995")] pub const fn write_copy_of_slice(&mut self, src: &[T]) -> &mut [T] where T: Copy, diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 471150cfd9671..2ee2093b66a5d 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -956,7 +956,6 @@ impl [T] { /// [`swap`]: slice::swap /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html #[unstable(feature = "slice_swap_unchecked", issue = "88539")] - #[rustc_const_unstable(feature = "slice_swap_unchecked", issue = "88539")] pub const unsafe fn swap_unchecked(&mut self, a: usize, b: usize) { assert_unsafe_precondition!( check_library_ub, @@ -3716,6 +3715,7 @@ impl [T] { #[inline] #[stable(feature = "copy_from_slice", since = "1.9.0")] #[rustc_const_unstable(feature = "const_copy_from_slice", issue = "131415")] + #[rustc_const_stable_indirect] #[track_caller] pub const fn copy_from_slice(&mut self, src: &[T]) where From 562880cfd96b4bf856ad4af1c3803fb75dc7bba9 Mon Sep 17 00:00:00 2001 From: Robert Bastian <4706271+robertbastian@users.noreply.github.com> Date: Mon, 24 Feb 2025 10:02:55 +0100 Subject: [PATCH 9/9] Update string.rs Co-authored-by: Amanieu d'Antras --- library/alloc/src/string.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index a222ce040a4a6..7fe823a34646a 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -966,8 +966,8 @@ impl String { /// This is highly unsafe, due to the number of invariants that aren't /// checked: /// - /// * all safety requirements for [`Vec::::from_raw_parts`] - /// * all safety requirements for [`String::from_utf8_unchecked`] + /// * all safety requirements for [`Vec::::from_raw_parts`]. + /// * all safety requirements for [`String::from_utf8_unchecked`]. /// /// Violating these may cause problems like corrupting the allocator's /// internal data structures. For example, it is normally **not** safe to