From 18037accccd8c26d003e57f3b51c6fc996dc9232 Mon Sep 17 00:00:00 2001 From: Wiktor Przetacznik <85874198+WiktorPrzetacznik@users.noreply.github.com> Date: Sat, 31 Aug 2024 16:12:16 +0200 Subject: [PATCH 1/4] Update map_unchecked safety section Update safety section that was probably copy-pasted from _mut version --- library/core/src/pin.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index 65f6bfb7ee176..779bdecda7f07 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -1522,8 +1522,7 @@ impl<'a, T: ?Sized> Pin<&'a T> { /// /// This function is unsafe. You must guarantee that the data you return /// will not move so long as the argument value does not move (for example, - /// because it is one of the fields of that value), and also that you do - /// not move out of the argument you receive to the interior function. + /// because it is one of the fields of that value). /// /// [`pin` module]: self#projections-and-structural-pinning #[stable(feature = "pin", since = "1.33.0")] From fa224f896c5be393504aad19a7efa72a165a1c4a Mon Sep 17 00:00:00 2001 From: Wiktor Przetacznik <85874198+WiktorPrzetacznik@users.noreply.github.com> Date: Sat, 31 Aug 2024 16:13:11 +0200 Subject: [PATCH 2/4] Fix typo --- library/core/src/str/iter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/str/iter.rs b/library/core/src/str/iter.rs index 681ec79c0b7bf..967979c8f9d4a 100644 --- a/library/core/src/str/iter.rs +++ b/library/core/src/str/iter.rs @@ -1287,7 +1287,7 @@ pub struct SplitAsciiWhitespace<'a> { } /// An iterator over the substrings of a string, -/// terminated by a substring matching to a predicate function +/// terminated by a substring matching to a predicate function. /// Unlike `Split`, it contains the matched part as a terminator /// of the subslice. /// From 1847da2431c553ad5e83e580dab89568c62ab0cf Mon Sep 17 00:00:00 2001 From: Wiktor Przetacznik <85874198+WiktorPrzetacznik@users.noreply.github.com> Date: Sat, 31 Aug 2024 16:16:55 +0200 Subject: [PATCH 3/4] Update panic section of reserve() and reserve_exact() The previous version mentioned panicing when capacity exceeds usize, but that's unprecise. More accurate note mentions isize::MAX --- 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 e628be1546f76..17a42c456bb10 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -1124,7 +1124,7 @@ impl String { /// /// # Panics /// - /// Panics if the new capacity overflows [`usize`]. + /// Panics if the new capacity exceeds [`isize::MAX`] bytes. /// /// # Examples /// @@ -1174,7 +1174,7 @@ impl String { /// /// # Panics /// - /// Panics if the new capacity overflows [`usize`]. + /// Panics if the new capacity exceeds [`isize::MAX`] bytes. /// /// # Examples /// From 8eb23d503af8739e53b6ae97ee1f2a0ebffaec86 Mon Sep 17 00:00:00 2001 From: Wiktor Przetacznik <85874198+WiktorPrzetacznik@users.noreply.github.com> Date: Sat, 31 Aug 2024 16:21:02 +0200 Subject: [PATCH 4/4] Introduce layout section in Saturating Document layout of Saturating, similarly to Wrapping --- library/core/src/num/saturating.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/core/src/num/saturating.rs b/library/core/src/num/saturating.rs index 3f4791e163e69..4119b204ac949 100644 --- a/library/core/src/num/saturating.rs +++ b/library/core/src/num/saturating.rs @@ -31,6 +31,10 @@ use crate::ops::{ /// /// assert_eq!(u32::MAX, (max + one).0); /// ``` +/// +/// # Layout +/// +/// `Saturating` is guaranteed to have the same layout and ABI as `T`. #[stable(feature = "saturating_int_impl", since = "1.74.0")] #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default, Hash)] #[repr(transparent)]