rust/library/core
Matthias Krüger fbed195b4d
Rollup merge of #133226 - compiler-errors:opt-in-pointer-like, r=lcnr
Make `PointerLike` opt-in instead of built-in

The `PointerLike` trait currently is a built-in trait that computes the layout of the type. This is a bit problematic, because types implement this trait automatically. Since this can be broken due to semver-compatible changes to a type's layout, this is undesirable. Also, calling `layout_of` in the trait system also causes cycles.

This PR makes the trait implemented via regular impls, and adds additional validation on top to make sure that those impls are valid. This could eventually be `derive()`d for custom smart pointers, and we can trust *that* as a semver promise rather than risking library authors accidentally breaking it.

On the other hand, we may never expose `PointerLike`, but at least now the implementation doesn't invoke `layout_of` which could cause ICEs or cause cycles.

Right now for a `PointerLike` impl to be valid, it must be an ADT that is `repr(transparent)` and the non-1zst field needs to implement `PointerLike`. There are also some primitive impls for `&T`/ `&mut T`/`*const T`/`*mut T`/`Box<T>`.
2024-11-20 20:10:13 +01:00
..
benches Auto merge of #122770 - iximeow:ixi/int-formatting-optimization, r=workingjubilee 2024-11-14 04:17:20 +00:00
src Rollup merge of #133226 - compiler-errors:opt-in-pointer-like, r=lcnr 2024-11-20 20:10:13 +01:00
tests Stabilize const_pin_2 2024-11-20 07:54:12 -05:00
Cargo.toml Port std library to RTEMS 2024-09-03 09:19:29 +02:00