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 1/2] 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 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 2/2] 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