diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-12-22 09:12:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-22 09:12:11 +0100 |
| commit | 7f36ae400cdfef370ba5410b382f533bc8b9d2cc (patch) | |
| tree | 60e9744c113b532ff25d9f63d7859259fc6a68e0 | |
| parent | 87be70e2b441f52eaf6698fa32538c146e6deeea (diff) | |
| parent | da6616c54fad4af6459feaebd48bedb2cc7fae08 (diff) | |
| download | rust-7f36ae400cdfef370ba5410b382f533bc8b9d2cc.tar.gz rust-7f36ae400cdfef370ba5410b382f533bc8b9d2cc.zip | |
Rollup merge of #134602 - kpreid:pointerlike-doc, r=tgross35
Document `PointerLike` implementation restrictions. Since <https://github.com/rust-lang/rust/pull/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)
| -rw-r--r-- | library/core/src/marker.rs | 10 |
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( |
