Skip to content

Commit f9ae08f

Browse files
committed
Correct documentation for PointerLike about automatic implementation.
Since <#133226>, it is no longer automatically implemented, but must be manually implemented, with special restrictions. The documentation now (roughly) explains those special restrictions.
1 parent bad2aa4 commit f9ae08f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

library/core/src/marker.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,14 @@ pub trait Tuple {}
972972

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

0 commit comments

Comments
 (0)