about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-07-20 13:20:08 +0200
committerRalf Jung <post@ralfj.de>2019-07-20 13:20:08 +0200
commit2e6b13a649ce4a8f5a608d10133dd2b4b30c35c1 (patch)
tree7e5768cd1e6b53d38f0517baeebd1f3974ebdf31 /src
parent21b502b275ca7d9a7f43c4e1cf09b0b547ecc645 (diff)
downloadrust-2e6b13a649ce4a8f5a608d10133dd2b4b30c35c1.tar.gz
rust-2e6b13a649ce4a8f5a608d10133dd2b4b30c35c1.zip
references must be aligned; also move up the warning that fn ptrs must be non-NULL
Diffstat (limited to 'src')
-rw-r--r--src/libstd/primitive_docs.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs
index cab58799d68..95b803e3461 100644
--- a/src/libstd/primitive_docs.rs
+++ b/src/libstd/primitive_docs.rs
@@ -895,9 +895,9 @@ mod prim_usize { }
 /// A reference represents a borrow of some owned value. You can get one by using the `&` or `&mut`
 /// operators on a value, or by using a `ref` or `ref mut` pattern.
 ///
-/// For those familiar with pointers, a reference is just a pointer that is assumed to not be null.
-/// In fact, `Option<&T>` has the same memory representation as a nullable pointer, and can be
-/// passed across FFI boundaries as such.
+/// For those familiar with pointers, a reference is just a pointer that is assumed to be
+/// aligned and not null. In fact, `Option<&T>` has the same memory representation as a
+/// nullable but aligned pointer, and can be passed across FFI boundaries as such.
 ///
 /// In most cases, references can be used much like the original value. Field access, method
 /// calling, and indexing work the same (save for mutability rules, of course). In addition, the
@@ -1040,6 +1040,11 @@ mod prim_ref { }
 /// [`FnMut`]: ops/trait.FnMut.html
 /// [`FnOnce`]: ops/trait.FnOnce.html
 ///
+/// Function pointers are pointers that point to *code*, not data. They can be called
+/// just like functions. Like references, function pointers are assumed to not be null,
+/// so if you want to pass a function pointer over FFI and be able to accommodate null pointers,
+/// make your type `Option<fn()>` with your required signature.
+///
 /// Plain function pointers are obtained by casting either plain functions, or closures that don't
 /// capture an environment:
 ///
@@ -1095,10 +1100,6 @@ mod prim_ref { }
 ///
 /// These markers can be combined, so `unsafe extern "stdcall" fn()` is a valid type.
 ///
-/// Like references in rust, function pointers are assumed to not be null, so if you want to pass a
-/// function pointer over FFI and be able to accommodate null pointers, make your type
-/// `Option<fn()>` with your required signature.
-///
 /// Function pointers implement the following traits:
 ///
 /// * [`Clone`]