diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-12-22 03:49:45 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-22 03:49:45 +0100 |
| commit | 9b4e40dcb83f60a975340a75c58284d043ee8268 (patch) | |
| tree | 3064173d6924186243c1a0e63f0765513c1ce48b | |
| parent | 239b7e83371fa0a5ee95ea944ea2ac6ac1fa7395 (diff) | |
| parent | 466335205f702edc38fc06dcb45a3b1e424ccecb (diff) | |
| download | rust-9b4e40dcb83f60a975340a75c58284d043ee8268.tar.gz rust-9b4e40dcb83f60a975340a75c58284d043ee8268.zip | |
Rollup merge of #134630 - fifty-six:master, r=workingjubilee
Use `&raw` for `ptr` primitive docs Fixes the first item in #133024
| -rw-r--r-- | library/core/src/primitive_docs.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index e105ceadff7..c5f029363e5 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -563,11 +563,11 @@ impl () {} /// Note that here the call to [`drop`] is for clarity - it indicates /// that we are done with the given value and it should be destroyed. /// -/// ## 3. Create it using `ptr::addr_of!` +/// ## 3. Create it using `&raw` /// -/// Instead of coercing a reference to a raw pointer, you can use the macros -/// [`ptr::addr_of!`] (for `*const T`) and [`ptr::addr_of_mut!`] (for `*mut T`). -/// These macros allow you to create raw pointers to fields to which you cannot +/// Instead of coercing a reference to a raw pointer, you can use the raw borrow +/// operators `&raw const` (for `*const T`) and `&raw mut` (for `*mut T`). +/// These operators allow you to create raw pointers to fields to which you cannot /// create a reference (without causing undefined behavior), such as an /// unaligned field. This might be necessary if packed structs or uninitialized /// memory is involved. @@ -580,7 +580,7 @@ impl () {} /// unaligned: u32, /// } /// let s = S::default(); -/// let p = std::ptr::addr_of!(s.unaligned); // not allowed with coercion +/// let p = &raw const s.unaligned; // not allowed with coercion /// ``` /// /// ## 4. Get it from C. |
