0
0
mirror of https://github.com/rust-lang/rust.git synced 2024-11-21 22:01:17 +01:00
rust/library
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
..
alloc Make PointerLike opt-in as a trait 2024-11-20 16:36:12 +00:00
backtrace@230570f2da
core Rollup merge of #133226 - compiler-errors:opt-in-pointer-like, r=lcnr 2024-11-20 20:10:13 +01:00
panic_abort
panic_unwind
portable-simd
proc_macro
profiler_builtins
rtstartup
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Rollup merge of #130800 - bjoernager:const-mut-cursor, r=joshtriplett 2024-11-20 20:10:12 +01:00
stdarch@e5e00aab0a Bump stdarch to the latest master 2024-11-18 18:52:27 +01:00
sysroot
test Update thread spawn hooks. 2024-11-19 18:54:20 +01:00
unwind
windows_targets
Cargo.lock
Cargo.toml