Rollup merge of #83579 - RalfJung:ptr-arithmetic, r=dtolnay
Improve pointer arithmetic docs * Add slightly more detailed definition of "allocated object" to the module docs, and link it from everywhere. * Clarify the "remains attached" wording a bit (at least I hope this is clearer). * Remove the sentence about using integer arithmetic; this seems to confuse people even if it is technically correct. As usual, the edit needs to be done in a dozen places to remain consistent, I hope I got them all.
This commit is contained in:
commit
5b67543c98
3 changed files with 47 additions and 55 deletions
|
@ -55,6 +55,14 @@
|
|||
//! has size 0, i.e., even if memory is not actually touched. Consider using
|
||||
//! [`NonNull::dangling`] in such cases.
|
||||
//!
|
||||
//! ## Allocated object
|
||||
//!
|
||||
//! For several operations, such as [`offset`] or field projections (`expr.field`), the notion of an
|
||||
//! "allocated object" becomes relevant. An allocated object is a contiguous region of memory.
|
||||
//! Common examples of allocated objects include stack-allocated variables (each variable is a
|
||||
//! separate allocated object), heap allocations (each allocation created by the global allocator is
|
||||
//! a separate allocated object), and `static` variables.
|
||||
//!
|
||||
//! [aliasing]: ../../nomicon/aliasing.html
|
||||
//! [book]: ../../book/ch19-01-unsafe-rust.html#dereferencing-a-raw-pointer
|
||||
//! [ub]: ../../reference/behavior-considered-undefined.html
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue