Update some wording making reference to issues/RFCs

pull/271/head
Yuki Okushi 3 years ago
parent 1fe5457479
commit 4b6eb0ff96

@ -172,10 +172,10 @@ of UB.
There is [an accepted RFC][extern-types] to add proper types with an unknown size, There is [an accepted RFC][extern-types] to add proper types with an unknown size,
called *extern types*, which would let Rust developers model things like C's `void*` called *extern types*, which would let Rust developers model things like C's `void*`
and other "declared but never defined" types more accurately. However as of and other "declared but never defined" types more accurately. However as of
Rust 2018, the feature is stuck in limbo over how `size_of::<MyExternType>()` Rust 2018, [the feature is stuck in limbo over how `size_of_val::<MyExternType>()`
should behave. should behave][extern-types-issue].
[dst-issue]: https://github.com/rust-lang/rust/issues/26403
[extern-types]: https://github.com/rust-lang/rfcs/blob/master/text/1861-extern-types.md [extern-types]: https://github.com/rust-lang/rfcs/blob/master/text/1861-extern-types.md
[extern-types-issue]: https://github.com/rust-lang/rust/issues/43467
[`str`]: ../std/primitive.str.html [`str`]: ../std/primitive.str.html
[slice]: ../std/primitive.slice.html [slice]: ../std/primitive.slice.html

@ -15,7 +15,7 @@ reinterpreting values as a different type.
We strongly recommend using [rust-bindgen][] and/or [cbindgen][] to manage your FFI We strongly recommend using [rust-bindgen][] and/or [cbindgen][] to manage your FFI
boundaries for you. The Rust team works closely with those projects to ensure boundaries for you. The Rust team works closely with those projects to ensure
that they work robustly and are compatible with current and future guarantees that they work robustly and are compatible with current and future guarantees
about type layouts and reprs. about type layouts and `repr`s.
The interaction of `repr(C)` with Rust's more exotic data layout features must be The interaction of `repr(C)` with Rust's more exotic data layout features must be
kept in mind. Due to its dual purpose as "for FFI" and "for layout control", kept in mind. Due to its dual purpose as "for FFI" and "for layout control",
@ -92,7 +92,7 @@ manipulate its tag and fields. See [the RFC][really-tagged] for details.
Adding an explicit `repr` to an enum suppresses the null-pointer Adding an explicit `repr` to an enum suppresses the null-pointer
optimization. optimization.
These reprs have no effect on a struct. These `repr`s have no effect on a struct.
## repr(packed) ## repr(packed)
@ -107,7 +107,8 @@ compiler might be able to paper over alignment issues with shifts and masks.
However if you take a reference to a packed field, it's unlikely that the However if you take a reference to a packed field, it's unlikely that the
compiler will be able to emit code to avoid an unaligned load. compiler will be able to emit code to avoid an unaligned load.
**[As of Rust 2018, this still can cause undefined behavior.][ub loads]** [As this can cause undefined behavior][ub loads], the lint has been implemented
and it will become a hard error.
`repr(packed)` is not to be used lightly. Unless you have extreme requirements, `repr(packed)` is not to be used lightly. Unless you have extreme requirements,
this should not be used. this should not be used.

@ -137,7 +137,7 @@ also cannot use `&mut base_ptr.field` as that would be creating a
reference. Thus, it is currently not possible to create a raw pointer to a field reference. Thus, it is currently not possible to create a raw pointer to a field
of a partially initialized struct, and also not possible to initialize a single of a partially initialized struct, and also not possible to initialize a single
field of a partially initialized struct. (a field of a partially initialized struct. (a
[solution to this problem](https://github.com/rust-lang/rfcs/pull/2582) is being [solution to this problem](https://github.com/rust-lang/rust/issues/64490) is being
worked on). worked on).
One last remark: when reading old Rust code, you might stumble upon the One last remark: when reading old Rust code, you might stumble upon the

Loading…
Cancel
Save