Skip to content

Commit

Permalink
add missing allocator safety in alloc crate
Browse files Browse the repository at this point in the history
  • Loading branch information
DiuDiu777 committed Jan 21, 2025
1 parent b605c65 commit 2fd6296
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,8 @@ impl<T: ?Sized> Box<T> {
/// memory problems. For example, a double-free may occur if the
/// function is called twice on the same `NonNull` pointer.
///
/// The non-null pointer must point to a block of memory allocated by the global allocator.
///
/// The safety conditions are described in the [memory layout] section.
///
/// # Examples
Expand Down Expand Up @@ -1170,7 +1172,7 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
/// memory problems. For example, a double-free may occur if the
/// function is called twice on the same raw pointer.
///
/// The raw pointer must point to a block of memory allocated by `alloc`
/// The raw pointer must point to a block of memory allocated by `alloc`.
///
/// # Examples
///
Expand Down Expand Up @@ -1225,6 +1227,7 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
/// memory problems. For example, a double-free may occur if the
/// function is called twice on the same raw pointer.
///
/// The non-null pointer must point to a block of memory allocated by `alloc`.
///
/// # Examples
///
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2740,7 +2740,7 @@ impl<T: ?Sized> Weak<T> {
/// # Safety
///
/// The pointer must have originated from the [`into_raw`] and must still own its potential
/// weak reference.
/// weak reference, and must point to a block of memory allocated by global allocator.
///
/// It is allowed for the strong count to be 0 at the time of calling this. Nevertheless, this
/// takes ownership of one weak reference currently represented as a raw pointer (the weak
Expand Down

0 comments on commit 2fd6296

Please sign in to comment.