about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-02-29 14:07:20 +0100
committerRalf Jung <post@ralfj.de>2020-02-29 14:07:20 +0100
commit0edc90cd1884c945b00512d2dede33c8a725ceb4 (patch)
tree3a8eda032a121e03c487ce61a6ed4e164a9a37e9 /src/liballoc
parentb961a03060aaac336269eb1703391a32f4de9dfd (diff)
downloadrust-0edc90cd1884c945b00512d2dede33c8a725ceb4.tar.gz
rust-0edc90cd1884c945b00512d2dede33c8a725ceb4.zip
clarify alignment requirements in Vec::from_raw_parts
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/vec.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
index 29987ac44e6..fc50d06b33c 100644
--- a/src/liballoc/vec.rs
+++ b/src/liballoc/vec.rs
@@ -404,7 +404,10 @@ impl<T> Vec<T> {
     ///
     /// * `ptr` needs to have been previously allocated via [`String`]/`Vec<T>`
     ///   (at least, it's highly likely to be incorrect if it wasn't).
-    /// * `ptr`'s `T` needs to have the same size and alignment as it was allocated with.
+    /// * `T` needs to have the same size and alignment as what `ptr` was allocated with.
+    ///   (`T` having a less strict alignment is not sufficient, the alignment really
+    ///   needs to be equal to satsify the [`dealloc`] requirement that memory must be
+    ///   allocated and deallocated with the same layout.)
     /// * `length` needs to be less than or equal to `capacity`.
     /// * `capacity` needs to be the capacity that the pointer was allocated with.
     ///
@@ -423,6 +426,7 @@ impl<T> Vec<T> {
     /// function.
     ///
     /// [`String`]: ../../std/string/struct.String.html
+    /// [`dealloc`]: ../../alloc/alloc/trait.GlobalAlloc.html#tymethod.dealloc
     ///
     /// # Examples
     ///