Skip to content

Commit 9ab5dc3

Browse files
kpreidgitbot
authored and
gitbot
committed
Document PointerLike implementation restrictions.
1 parent 492efd3 commit 9ab5dc3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

core/src/marker.rs

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

983983
/// A marker for pointer-like types.
984984
///
985-
/// This trait can only be implemented for types that have the same size and alignment
986-
/// as a `usize` or `*const ()`.
985+
/// This trait can only be implemented for types that are certain to have
986+
/// the same size and alignment as a [`usize`] or [`*const ()`](pointer).
987+
/// To ensure this, there are special requirements on implementations
988+
/// of `PointerLike` (other than the already-provided implementations
989+
/// for built-in types):
990+
///
991+
/// * The type must have `#[repr(transparent)]`.
992+
/// * The type’s sole non-zero-sized field must itself implement `PointerLike`.
987993
#[unstable(feature = "pointer_like_trait", issue = "none")]
988994
#[lang = "pointer_like"]
989995
#[diagnostic::on_unimplemented(

0 commit comments

Comments
 (0)