@@ -1999,9 +1999,18 @@ impl<F: FnPtr> fmt::Debug for F {
19991999/// as all other references. This macro can create a raw pointer *without* creating
20002000/// a reference first.
20012001///
2002- /// Note, however, that the `expr` in `addr_of!(expr)` is still subject to all
2003- /// the usual rules. In particular, `addr_of!(*ptr::null())` is Undefined
2004- /// Behavior because it dereferences a null pointer.
2002+ /// The `expr` in `addr_of!(expr)` is evaluated as a place expression, but never loads
2003+ /// from the place or requires the place to be dereferenceable. This means that
2004+ /// `addr_of!(*ptr)` is defined behavior even if `ptr` is null, dangling, or misaligned.
2005+ /// Note however that `addr_of!((*ptr).field)` still requires the projection to
2006+ /// `field` to be in-bounds, using the same rules as [`offset`].
2007+ ///
2008+ /// Note that `Deref`/`Index` coercions (and their mutable counterparts) are applied inside
2009+ /// `addr_of!` like everywhere else, in which case a reference is created to call `Deref::deref` or
2010+ /// `Index::index`, respectively. The statements above only apply when no such coercions are
2011+ /// applied.
2012+ ///
2013+ /// [`offset`]: pointer::offset
20052014///
20062015/// # Example
20072016///
@@ -2039,9 +2048,18 @@ pub macro addr_of($place:expr) {
20392048/// as all other references. This macro can create a raw pointer *without* creating
20402049/// a reference first.
20412050///
2042- /// Note, however, that the `expr` in `addr_of_mut!(expr)` is still subject to all
2043- /// the usual rules. In particular, `addr_of_mut!(*ptr::null_mut())` is Undefined
2044- /// Behavior because it dereferences a null pointer.
2051+ /// The `expr` in `addr_of_mut!(expr)` is evaluated as a place expression, but never loads
2052+ /// from the place or requires the place to be dereferenceable. This means that
2053+ /// `addr_of_mut!(*ptr)` is defined behavior even if `ptr` is null, dangling, or misaligned.
2054+ /// Note however that `addr_of_mut!((*ptr).field)` still requires the projection to
2055+ /// `field` to be in-bounds, using the same rules as [`offset`].
2056+ ///
2057+ /// Note that `Deref`/`Index` coercions (and their mutable counterparts) are applied inside
2058+ /// `addr_of_mut!` like everywhere else, in which case a reference is created to call `Deref::deref`
2059+ /// or `Index::index`, respectively. The statements above only apply when no such coercions are
2060+ /// applied.
2061+ ///
2062+ /// [`offset`]: pointer::offset
20452063///
20462064/// # Examples
20472065///
0 commit comments