|
150 | 150 | //! absent, in which case the pointer does not have permission to access any memory.
|
151 | 151 | //!
|
152 | 152 | //! The exact structure of provenance is not yet specified, but the permission defined by a
|
153 |
| -//! pointer's provenance have both a *spatial* and *temporal* component: |
| 153 | +//! pointer's provenance have a *spatial* component, a *temporal* component, and a *mutability* |
| 154 | +//! component: |
154 | 155 | //!
|
155 | 156 | //! * Spatial: The set of memory addresses that the pointer is allowed to access.
|
156 | 157 | //! * Temporal: The timespan during which the pointer is allowed to access those memory addresses.
|
| 158 | +//! * Mutability: Whether the pointer may only access the memory for reads, or also access it for |
| 159 | +//! writes. Note that this can interact with the other components, e.g. a pointer might permit |
| 160 | +//! mutation only for a subset of addresses, or only for a subset of its maximal timespan. |
157 | 161 | //!
|
158 | 162 | //! When an [allocated object] is created, it has a unique Original Pointer. For alloc
|
159 | 163 | //! APIs this is literally the pointer the call returns, and for local variables and statics,
|
|
177 | 181 | //! Whether and when exactly the provenance of a reference gets "shrunk" to *exactly* fit
|
178 | 182 | //! the memory it points to is not yet determined.
|
179 | 183 | //!
|
| 184 | +//! A *shared* reference only ever has provenance that permits reading from memory, |
| 185 | +//! and never permits writes, except inside [`UnsafeCell`]. |
| 186 | +//! |
180 | 187 | //! Provenance can affect whether a program has undefined behavior:
|
181 | 188 | //!
|
182 | 189 | //! * It is undefined behavior to access memory through a pointer that does not have provenance over
|
|
380 | 387 | //! [Miri]: https://github.com/rust-lang/miri
|
381 | 388 | //! [CHERI]: https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/
|
382 | 389 | //! [Strict Provenance]: #strict-provenance
|
| 390 | +//! [`UnsafeCell`]: core::cell::UnsafeCell |
383 | 391 |
|
384 | 392 | #![stable(feature = "rust1", since = "1.0.0")]
|
385 | 393 | // There are many unsafe functions taking pointers that don't dereference them.
|
|
0 commit comments