From 878a79691caa5b02bb8a91f10866903a4af8b523 Mon Sep 17 00:00:00 2001 From: LemonJ <1632798336@qq.com> Date: Thu, 19 Dec 2024 13:54:37 +0800 Subject: [PATCH 1/2] Add missing safety descriptions to Arc's 'from_raw','increment_strong_count','decrement_strong_count' --- library/alloc/src/sync.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 6cf41a3fa4e16..dd899c8a71d0d 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1376,6 +1376,8 @@ impl Arc { /// different types. See [`mem::transmute`][transmute] for more information /// on what restrictions apply in this case. /// + /// The raw pointer must point to a block of memory allocated by the global allocator + /// /// The user of `from_raw` has to make sure a specific value of `T` is only /// dropped once. /// @@ -1431,7 +1433,8 @@ impl Arc { /// /// The pointer must have been obtained through `Arc::into_raw`, and the /// associated `Arc` instance must be valid (i.e. the strong count must be at - /// least 1) for the duration of this method. + /// least 1) for the duration of this method, and `ptr` must point to a block of memory + /// allocated by the global allocator. /// /// # Examples /// @@ -1465,7 +1468,8 @@ impl Arc { /// /// The pointer must have been obtained through `Arc::into_raw`, and the /// associated `Arc` instance must be valid (i.e. the strong count must be at - /// least 1) when invoking this method. This method can be used to release the final + /// least 1) when invoking this method, and `ptr` must point to a block of memory + /// allocated by the global allocator. This method can be used to release the final /// `Arc` and backing storage, but **should not** be called after the final `Arc` has been /// released. /// From 48e671ec88386f29ab2e3840a6fde3645abbc085 Mon Sep 17 00:00:00 2001 From: ClearLove <98693523+DiuDiu777@users.noreply.github.com> Date: Thu, 16 Jan 2025 15:16:43 +0800 Subject: [PATCH 2/2] fix typo in library/alloc/src/sync.rs Co-authored-by: Ibraheem Ahmed --- library/alloc/src/sync.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index dd899c8a71d0d..f7201a5ec2fcf 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1376,7 +1376,7 @@ impl Arc { /// different types. See [`mem::transmute`][transmute] for more information /// on what restrictions apply in this case. /// - /// The raw pointer must point to a block of memory allocated by the global allocator + /// The raw pointer must point to a block of memory allocated by the global allocator. /// /// The user of `from_raw` has to make sure a specific value of `T` is only /// dropped once.