Skip to content

Commit

Permalink
Correct documentation for PointerLike about automatic implementation.
Browse files Browse the repository at this point in the history
Since <#133226>, it is no longer
automatically implemented, but must be manually implemented, with
special restrictions. The documentation now (roughly) explains those
special restrictions.
  • Loading branch information
kpreid committed Dec 21, 2024
1 parent bad2aa4 commit f9ae08f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions library/core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,14 @@ pub trait Tuple {}

/// A marker for pointer-like types.
///
/// All types that have the same size and alignment as a `usize` or
/// `*const ()` automatically implement this trait.
/// This trait may only be implemented for types that are certain to have
/// the same size and alignment as a [`usize`] or [`*const ()`](pointer).
/// To ensure this, there are special requirements on implementations
/// of `PointerLike` (other than the already-provided implementations
/// for built-in types):
///
/// * The type must have `#[repr(transparent)]`.
/// * The type’s sole non-zero-sized field must itself implement `PointerLike`.
#[unstable(feature = "pointer_like_trait", issue = "none")]
#[lang = "pointer_like"]
#[diagnostic::on_unimplemented(
Expand Down

0 comments on commit f9ae08f

Please sign in to comment.