about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKevin Reid <kpreid@switchb.org>2024-12-20 14:58:37 -0800
committerKevin Reid <kpreid@switchb.org>2024-12-20 20:47:03 -0800
commitda6616c54fad4af6459feaebd48bedb2cc7fae08 (patch)
treedebc6a4658d71a6c6f323213d718da417aa1a18a
parent13170cd787cb733ed24842ee825bcbd98dc01476 (diff)
downloadrust-da6616c54fad4af6459feaebd48bedb2cc7fae08.tar.gz
rust-da6616c54fad4af6459feaebd48bedb2cc7fae08.zip
Document `PointerLike` implementation restrictions.
-rw-r--r--library/core/src/marker.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs
index 3d79706f8ec..d0d8609f43f 100644
--- a/library/core/src/marker.rs
+++ b/library/core/src/marker.rs
@@ -982,8 +982,14 @@ pub trait Tuple {}
 
 /// A marker for pointer-like types.
 ///
-/// This trait can only be implemented for types that have the same size and alignment
-/// as a `usize` or `*const ()`.
+/// This trait can 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(