Skip to content

Commit 941193a

Browse files
committed
Add missing safety descriptions to Arc's 'from_raw','increment_strong_count','decrement_strong_count'
1 parent 604d669 commit 941193a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

library/alloc/src/sync.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1376,9 +1376,11 @@ impl<T: ?Sized> Arc<T> {
13761376
/// different types. See [`mem::transmute`][transmute] for more information
13771377
/// on what restrictions apply in this case.
13781378
///
1379+
/// The raw pointer must point to a block of memory allocated by the global allocator
1380+
///
13791381
/// The user of `from_raw` has to make sure a specific value of `T` is only
13801382
/// dropped once.
1381-
///
1383+
///
13821384
/// This function is unsafe because improper use may lead to memory unsafety,
13831385
/// even if the returned `Arc<T>` is never accessed.
13841386
///
@@ -1431,7 +1433,8 @@ impl<T: ?Sized> Arc<T> {
14311433
///
14321434
/// The pointer must have been obtained through `Arc::into_raw`, and the
14331435
/// associated `Arc` instance must be valid (i.e. the strong count must be at
1434-
/// least 1) for the duration of this method.
1436+
/// least 1) for the duration of this method, and `ptr` must point to a block of memory
1437+
/// allocated by the global allocator.
14351438
///
14361439
/// # Examples
14371440
///
@@ -1465,7 +1468,8 @@ impl<T: ?Sized> Arc<T> {
14651468
///
14661469
/// The pointer must have been obtained through `Arc::into_raw`, and the
14671470
/// associated `Arc` instance must be valid (i.e. the strong count must be at
1468-
/// least 1) when invoking this method. This method can be used to release the final
1471+
/// least 1) when invoking this method, and `ptr` must point to a block of memory
1472+
/// allocated by the global allocator. This method can be used to release the final
14691473
/// `Arc` and backing storage, but **should not** be called after the final `Arc` has been
14701474
/// released.
14711475
///

0 commit comments

Comments
 (0)