about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-07-20 13:19:36 +0200
committerRalf Jung <post@ralfj.de>2019-07-20 13:19:36 +0200
commit21b502b275ca7d9a7f43c4e1cf09b0b547ecc645 (patch)
tree3a8c0ff2ad49c6a1f430a3ada798bf567a719fe7 /src/libstd
parente9d22273283dce210b26362aa0dcc3fc10bf7e81 (diff)
downloadrust-21b502b275ca7d9a7f43c4e1cf09b0b547ecc645.tar.gz
rust-21b502b275ca7d9a7f43c4e1cf09b0b547ecc645.zip
warn that raw pointers must be aligned when used, and that writes cause drop
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/primitive_docs.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs
index 65fd8c83e1c..cab58799d68 100644
--- a/src/libstd/primitive_docs.rs
+++ b/src/libstd/primitive_docs.rs
@@ -362,8 +362,11 @@ mod prim_unit { }
 ///
 /// *[See also the `std::ptr` module](ptr/index.html).*
 ///
-/// Working with raw pointers in Rust is uncommon,
-/// typically limited to a few patterns.
+/// Working with raw pointers in Rust is uncommon, typically limited to a few patterns.
+/// Raw pointers can be unaligned or null when unused. However, when a raw pointer is used to
+/// load/store data from/to memory, they must be non-null and aligned.
+/// Storing through a raw pointer (`*ptr = data`) calls `drop` on the old value, so
+/// [`write`] must be used if memory is not already initialized.
 ///
 /// Use the [`null`] and [`null_mut`] functions to create null pointers, and the
 /// [`is_null`] method of the `*const T` and `*mut T` types to check for null.
@@ -442,6 +445,7 @@ mod prim_unit { }
 /// [`offset`]: ../std/primitive.pointer.html#method.offset
 /// [`into_raw`]: ../std/boxed/struct.Box.html#method.into_raw
 /// [`drop`]: ../std/mem/fn.drop.html
+/// [`write`]: ../std/ptr/fn.write.html
 #[stable(feature = "rust1", since = "1.0.0")]
 mod prim_pointer { }