diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 38d843263ffda..69a9d726b3525 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -282,6 +282,9 @@ impl Arc { /// To avoid a memory leak the pointer must be converted back to an `Arc` using /// [`Arc::from_raw`][from_raw]. /// + /// If `T` is zero-sized (e.g. `Arc<()>`), the returned pointer address + /// will be meaningless. + /// /// [from_raw]: struct.Arc.html#method.from_raw /// /// # Examples diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 82d361fb0e853..59bd0fa9f5099 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -274,6 +274,9 @@ impl Box { /// proper way to do so is to convert the raw pointer back into a /// `Box` with the [`Box::from_raw`] function. /// + /// If `T` is zero-sized (e.g. `Box<()>`), the returned pointer address + /// will be meaningless. + /// /// Note: this is an associated function, which means that you have /// to call it as `Box::into_raw(b)` instead of `b.into_raw()`. This /// is so that there is no conflict with a method on the inner type. diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 6108a06634bb8..284700c0a3e06 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -359,6 +359,9 @@ impl Rc { /// To avoid a memory leak the pointer must be converted back to an `Rc` using /// [`Rc::from_raw`][from_raw]. /// + /// If `T` is zero-sized (e.g. `Rc<()>`), the returned pointer address + /// will be meaningless. + /// /// [from_raw]: struct.Rc.html#method.from_raw /// /// # Examples diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 2ea953df87357..a6cd1a384cd10 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -437,6 +437,9 @@ impl [T] { /// The caller must ensure that the slice outlives the pointer this /// function returns, or else it will end up pointing to garbage. /// + /// If the slice is empty, the returned pointer address will be + /// meaningless. + /// /// Modifying the slice may cause its buffer to be reallocated, which /// would also make any pointers to it invalid. /// @@ -463,6 +466,9 @@ impl [T] { /// The caller must ensure that the slice outlives the pointer this /// function returns, or else it will end up pointing to garbage. /// + /// If the slice is empty, the returned pointer address will be + /// meaningless. + /// /// Modifying the slice may cause its buffer to be reallocated, which /// would also make any pointers to it invalid. /// diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 87315fff0a07d..84583991fadb5 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -275,6 +275,9 @@ impl str { /// [`u8`]. This pointer will be pointing to the first byte of the string /// slice. /// + /// If the string slice is empty, the returned pointer address will be + /// meaningless. + /// /// [`u8`]: primitive.u8.html /// /// # Examples diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index ab44342ebf02f..b88dc10cb931f 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -235,6 +235,9 @@ impl Cell { /// Returns a raw pointer to the underlying data in this cell. /// + /// If `T` is zero-sized (e.g. `Cell<()>`), the returned pointer address + /// will be meaningless. + /// /// # Examples /// /// ``` @@ -771,6 +774,9 @@ impl RefCell { /// Returns a raw pointer to the underlying data in this cell. /// + /// If `T` is zero-sized (e.g. `RefCell<()>`), the returned pointer address + /// will be meaningless. + /// /// # Examples /// /// ``` @@ -1188,6 +1194,9 @@ impl UnsafeCell { /// `&mut T`, and ensure that there are no mutations or mutable /// aliases going on when casting to `&T` /// + /// If `T` is zero-sized (e.g. `UnsafeCell<()>`), the returned pointer + /// address will be meaningless. + /// /// # Examples /// /// ```