summaryrefslogtreecommitdiffstats
path: root/src/doc/nomicon
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc/nomicon')
-rw-r--r--src/doc/nomicon/src/dropck.md2
-rw-r--r--src/doc/nomicon/src/ffi.md21
-rw-r--r--src/doc/nomicon/src/send-and-sync.md5
-rw-r--r--src/doc/nomicon/src/subtyping.md2
4 files changed, 17 insertions, 13 deletions
diff --git a/src/doc/nomicon/src/dropck.md b/src/doc/nomicon/src/dropck.md
index 75940219c..4063d5619 100644
--- a/src/doc/nomicon/src/dropck.md
+++ b/src/doc/nomicon/src/dropck.md
@@ -250,7 +250,7 @@ fn main() {
inspector: None,
days: Box::new(1),
};
- world.inspector = Some(Inspector(&world.days, "gatget"));
+ world.inspector = Some(Inspector(&world.days, "gadget"));
}
```
diff --git a/src/doc/nomicon/src/ffi.md b/src/doc/nomicon/src/ffi.md
index 8d1a882b3..684e7125b 100644
--- a/src/doc/nomicon/src/ffi.md
+++ b/src/doc/nomicon/src/ffi.md
@@ -721,17 +721,20 @@ No `transmute` required!
## FFI and unwinding
-It’s important to be mindful of unwinding when working with FFI. Each
-non-`Rust` ABI comes in two variants, one with `-unwind` suffix and one without. If
-you expect Rust `panic`s or foreign (e.g. C++) exceptions to cross an FFI
-boundary, that boundary must use the appropriate `-unwind` ABI string (note
-that compiling with `panic=abort` will still cause `panic!` to immediately
-abort the process, regardless of which ABI is specified by the function that
-`panic`s).
+It’s important to be mindful of unwinding when working with FFI. Most
+ABI strings come in two variants, one with an `-unwind` suffix and one without.
+The `Rust` ABI always permits unwinding, so there is no `Rust-unwind` ABI.
+If you expect Rust `panic`s or foreign (e.g. C++) exceptions to cross an FFI
+boundary, that boundary must use the appropriate `-unwind` ABI string.
Conversely, if you do not expect unwinding to cross an ABI boundary, use one of
-the non-`unwind` ABI strings (other than `Rust`, which always permits
-unwinding). If an unwinding operation does encounter an ABI boundary that is
+the non-`unwind` ABI strings.
+
+> Note: Compiling with `panic=abort` will still cause `panic!` to immediately
+abort the process, regardless of which ABI is specified by the function that
+`panic`s.
+
+If an unwinding operation does encounter an ABI boundary that is
not permitted to unwind, the behavior depends on the source of the unwinding
(Rust `panic` or a foreign exception):
diff --git a/src/doc/nomicon/src/send-and-sync.md b/src/doc/nomicon/src/send-and-sync.md
index 34539daa3..808a5c3ae 100644
--- a/src/doc/nomicon/src/send-and-sync.md
+++ b/src/doc/nomicon/src/send-and-sync.md
@@ -94,6 +94,7 @@ to the heap.
use std::{
mem::{align_of, size_of},
ptr,
+ cmp::max,
};
struct Carton<T>(ptr::NonNull<T>);
@@ -105,8 +106,8 @@ impl<T> Carton<T> {
let mut memptr: *mut T = ptr::null_mut();
unsafe {
let ret = libc::posix_memalign(
- (&mut memptr).cast(),
- align_of::<T>(),
+ (&mut memptr as *mut *mut T).cast(),
+ max(align_of::<T>(), size_of::<usize>()),
size_of::<T>()
);
assert_eq!(ret, 0, "Failed to allocate or invalid alignment");
diff --git a/src/doc/nomicon/src/subtyping.md b/src/doc/nomicon/src/subtyping.md
index 6f0c12db4..cc48a5970 100644
--- a/src/doc/nomicon/src/subtyping.md
+++ b/src/doc/nomicon/src/subtyping.md
@@ -339,7 +339,7 @@ lifetimes to be covariant: as soon as you try to stuff them in something like a
mutable reference, they inherit invariance and you're prevented from doing anything
bad.
-However Box makes it easier to focus on by-value aspect of references that we
+However, Box makes it easier to focus on the by-value aspect of references that we
partially glossed over.
Unlike a lot of languages which allow values to be freely aliased at all times,