Ammend Rc/Arc::from_raw() docs regarding unsafety

Constructing an Rc/Arc is unsafe even if the wrapped `T`
is never dereferenced.
This commit is contained in:
Lukas Lueg 2020-01-10 19:39:01 +01:00
parent f795e8a216
commit becebf3106
2 changed files with 8 additions and 6 deletions

View file

@ -573,10 +573,11 @@ impl<T: ?Sized> Rc<T> {
/// Constructs an `Rc` from a raw pointer.
///
/// The raw pointer must have been previously returned by a call to a
/// [`Rc::into_raw`][into_raw].
/// [`Rc::into_raw`][into_raw] using the same `T`.
///
/// This function is unsafe because improper use may lead to memory problems. For example, a
/// double-free may occur if the function is called twice on the same raw pointer.
/// This function is unsafe because improper use may lead to memory unsafety,
/// even if `T` is never accessed. For example, a double-free may occur if the function is
/// called twice on the same raw pointer.
///
/// [into_raw]: struct.Rc.html#method.into_raw
///

View file

@ -553,10 +553,11 @@ impl<T: ?Sized> Arc<T> {
/// Constructs an `Arc` from a raw pointer.
///
/// The raw pointer must have been previously returned by a call to a
/// [`Arc::into_raw`][into_raw].
/// [`Arc::into_raw`][into_raw], using the same `T`.
///
/// This function is unsafe because improper use may lead to memory problems. For example, a
/// double-free may occur if the function is called twice on the same raw pointer.
/// This function is unsafe because improper use may lead to memory unsafety,
/// even if `T` is never accessed. For example, a double-free may occur if the function is
/// called twice on the same raw pointer.
///
/// [into_raw]: struct.Arc.html#method.into_raw
///