Skip to content

Commit edcf16c

Browse files
authored
Unrolled build for rust-lang#134602
Rollup merge of rust-lang#134602 - kpreid:pointerlike-doc, r=tgross35 Document `PointerLike` implementation restrictions. Since <rust-lang#133226>, it is no longer automatically implemented, but must be manually implemented, with special restrictions. The documentation now (roughly) explains those special restrictions. cc `@compiler-errors` (author of the previous PR)
2 parents a2bcfae + da6616c commit edcf16c

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
@@ -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)