Rollup merge of #129653 - RalfJung:addr-of-read-only, r=scottmcm · patricklam/verify-rust-std@3e7e6cd (original) (raw)
`@@ -2277,6 +2277,14 @@ impl<F: FnPtr> fmt::Debug for F {
`
2277
2277
`` /// addr_of!(expr)
is equivalent to &raw const expr
. The macro is soft-deprecated;
``
2278
2278
`` /// use &raw const
instead.
``
2279
2279
`///
`
``
2280
`` +
/// It is still an open question under which conditions writing through an addr_of!
-created
``
``
2281
`` +
/// pointer is permitted. If the place expr
evaluates to is based on a raw pointer, then the
``
``
2282
`` +
/// result of addr_of!
inherits all permissions from that raw pointer. However, if the place is
``
``
2283
`` +
/// based on a reference, local variable, or static
, then until all details are decided, the same
``
``
2284
`+
/// rules as for shared references apply: it is UB to write through a pointer created with this
`
``
2285
`` +
/// operation, except for bytes located inside an UnsafeCell
. Use &raw mut
(or [addr_of_mut
])
``
``
2286
`+
/// to create a raw pointer that definitely permits mutation.
`
``
2287
`+
///
`
2280
2288
`` /// Creating a reference with &
/&mut
is only allowed if the pointer is properly aligned
``
2281
2289
`/// and points to initialized data. For cases where those requirements do not hold,
`
2282
2290
`` /// raw pointers should be used instead. However, &expr as *const _
creates a reference
``