Skip to content

Commit

Permalink
fixup ptr docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gankra committed Mar 23, 2022
1 parent e60b84b commit 8643aa4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
7 changes: 3 additions & 4 deletions library/core/src/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ impl<T: ?Sized> *const T {
/// and cannot be created from one without additional context.
///
/// If you would like to treat a pointer like an integer anyway,
/// see [`addr`][] and [`with_addr`][] for the responsible way to do that.
/// see [`addr`][#method.addr-1] and [`with_addr`][#method.with_addr-1] for the responsible
/// way to do that.
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
pub fn to_bits(self) -> [u8; core::mem::size_of::<*const ()>()]
where
Expand Down Expand Up @@ -109,7 +110,7 @@ impl<T: ?Sized> *const T {
/// and is equivalent to the deprecated `ptr as usize` cast.
///
/// On more complicated platforms like CHERI and segmented architectures,
/// this may remove some important metadata. See [`with_addr`][] for
/// this may remove some important metadata. See [`with_addr`][#method.with_addr-1] for
/// details on this distinction and why it's important.
#[unstable(feature = "strict_provenance", issue = "99999999")]
pub fn addr(self) -> usize
Expand All @@ -122,8 +123,6 @@ impl<T: ?Sized> *const T {

/// Creates a new pointer with the given address.
///
/// See also: [`ptr::fake_alloc`][] and [`ptr::zst_exists`][].
///
/// This replaces the deprecated `usize as ptr` cast, which had
/// fundamentally broken semantics because it couldn't restore
/// *segment* and *provenance*.
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
//! [zst]: ../../nomicon/exotic-sizes.html#zero-sized-types-zsts
//! [atomic operations]: crate::sync::atomic
//! [`offset`]: pointer::offset
//! [`zst_exists`]: pointer::zst_exists
//! [`zst_exists`]: core::ptr::zst_exists

#![stable(feature = "rust1", since = "1.0.0")]

Expand Down Expand Up @@ -337,7 +337,7 @@ where
/// This is a problem for Pointer Provenance and Segmenting, because there
/// is no "chain of custody" to an allocation. One possible solution to this
/// is for the programmer to Pretend To Be Malloc and "allocate" the address.
/// See [`with_addr`] for more details.
/// See [`pointer::with_addr`] for more details.
///
/// Just as with *real* malloc, the compiler is free to assume the pointer
/// returned from this function is completely unaliased, and that all accesses
Expand Down
7 changes: 3 additions & 4 deletions library/core/src/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ impl<T: ?Sized> *mut T {
/// and cannot be created from one without additional context.
///
/// If you would like to treat a pointer like an integer anyway,
/// see [`addr`][] and [`with_addr`][] for the responsible way to do that.
/// see [`addr`][#method.addr-1] and [`with_addr`][#method.with_addr-1] for
/// the responsible way to do that.
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
pub fn to_bits(self) -> [u8; core::mem::size_of::<*mut ()>()]
where
Expand Down Expand Up @@ -112,7 +113,7 @@ impl<T: ?Sized> *mut T {
/// and is equivalent to the deprecated `ptr as usize` cast.
///
/// On more complicated platforms like CHERI and segmented architectures,
/// this may remove some important metadata. See [`with_addr`][] for
/// this may remove some important metadata. See [`with_addr`][#method.with_addr-1] for
/// details on this distinction and why it's important.
#[unstable(feature = "strict_provenance", issue = "99999999")]
pub fn addr(self) -> usize
Expand All @@ -125,8 +126,6 @@ impl<T: ?Sized> *mut T {

/// Creates a new pointer with the given address.
///
/// See also: [`ptr::fake_alloc`][] and [`ptr::zst_exists`][].
///
/// This replaces the deprecated `usize as ptr` cast, which had
/// fundamentally broken semantics because it couldn't restore
/// *segment* and *provenance*.
Expand Down

0 comments on commit 8643aa4

Please sign in to comment.