rust/library/core/src
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 const_alloc_layout feature gate only about functions that are already stable 2024-11-01 14:32:59 +01:00
array Auto merge of #132458 - RalfJung:rustc-const-unstable, r=Amanieu 2024-11-03 02:32:48 +00:00
ascii Add more precondition check tests 2024-10-09 19:34:27 -04:00
async_iter Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
cell Re-do recursive const stability checks 2024-10-25 20:31:40 +02:00
char Auto merge of #132709 - programmerjake:optimize-charto_digit, r=joshtriplett 2024-11-14 14:14:40 +00:00
clone CloneToUninit: use a private specialization trait 2024-07-29 20:44:43 +03:00
cmp Use generic NonZero everywhere in core. 2024-02-22 15:17:33 +01:00
convert Fix doc nits 2024-07-26 13:26:33 +01:00
ffi Rollup merge of #132732 - gavincrawford:as_ptr_attribute, r=Urgau 2024-11-20 01:54:24 -05:00
fmt Auto merge of #133026 - workingjubilee:rollup-q8ig6ah, r=workingjubilee 2024-11-14 07:07:53 +00:00
future rustdoc-search: simplify rules for generics and type params 2024-10-30 12:27:48 -07:00
hash remove const_hash feature leftovers 2024-11-02 11:27:14 +01:00
intrinsics rename rustc_const_stable_intrinsic -> rustc_intrinsic_const_stable_indirect 2024-11-18 07:47:44 +01:00
io Fix doc nits 2024-07-26 13:26:33 +01:00
iter Remove do_not_const_check from Iterator methods 2024-10-30 19:24:34 +00:00
macros add const_eval_select macro to reduce redundancy 2024-11-05 09:26:08 +01:00
mem Rollup merge of #132732 - gavincrawford:as_ptr_attribute, r=Urgau 2024-11-20 01:54:24 -05:00
net get rid of a whole bunch of unnecessary rustc_const_unstable attributes 2024-11-02 09:59:55 +01:00
num Rollup merge of #132449 - RalfJung:is_val_statically_known, r=compiler-errors 2024-11-16 21:05:44 +01:00
ops Rollup merge of #132144 - adetaylor:receiver-trait-itself, r=wesleywiser 2024-11-11 21:58:29 +01:00
panic stabilize const_arguments_as_str 2024-11-03 07:49:24 +01:00
prelude Avoid comments that describe multiple use items. 2024-07-17 08:02:46 +10:00
ptr clean up const stability around UB checks 2024-11-16 22:50:22 +01:00
range Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
slice Rollup merge of #132732 - gavincrawford:as_ptr_attribute, r=Urgau 2024-11-20 01:54:24 -05:00
str Rollup merge of #132732 - gavincrawford:as_ptr_attribute, r=Urgau 2024-11-20 01:54:24 -05:00
sync Rollup merge of #131717 - tgross35:stabilize-const_atomic_from_ptr, r=RalfJung 2024-11-16 21:05:43 +01:00
task get rid of a whole bunch of unnecessary rustc_const_unstable attributes 2024-11-02 09:59:55 +01:00
unicode stabilize const_unicode_case_lookup 2024-11-12 15:13:31 +01:00
any.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
arch.rs update bootstrap configs 2024-10-15 20:30:23 -07:00
ascii.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
asserting.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
bool.rs [Clippy] Swap filter_map_bool_then to use diagnostic item instead of path 2024-09-19 13:13:42 +01:00
borrow.rs Suggest borrowing on fn argument that is impl AsRef 2024-05-09 23:25:31 +00:00
cell.rs Rollup merge of #132732 - gavincrawford:as_ptr_attribute, r=Urgau 2024-11-20 01:54:24 -05:00
clone.rs Make CloneToUninit dyn-compatible 2024-11-12 15:08:41 -06:00
cmp.rs library: consistently use American spelling for 'behavior' 2024-10-25 12:02:47 +02:00
default.rs update cfgs 2024-09-05 17:24:01 +01:00
error.md Mention core's PanicInfo in error.md. 2024-06-11 15:47:00 +02:00
error.rs Library: Rename "object safe" to "dyn compatible" 2024-10-09 18:48:29 +02:00
escape.rs Optimize escape_ascii 2024-10-09 17:17:50 -04:00
hint.rs Re-do recursive const stability checks 2024-10-25 20:31:40 +02:00
internal_macros.rs Fix doc nits 2024-07-26 13:26:33 +01:00
lib.miri.rs add 'x.py miri', and make it work for 'library/{core,alloc,std}' 2024-04-03 20:27:20 +02:00
lib.rs Stabilize const_pin_2 2024-11-20 07:54:12 -05:00
marker.rs Make PointerLike opt-in as a trait 2024-11-20 16:36:12 +00:00
option.rs stabilize const_option_ext 2024-11-12 21:42:15 +01:00
panic.rs const_panic: inline in bootstrap builds to avoid f16/f128 crashes 2024-11-18 18:17:02 +01:00
panicking.rs add const_eval_select macro to reduce redundancy 2024-11-05 09:26:08 +01:00
pat.rs Add tracking issue to core-pattern-type 2024-08-07 20:43:05 -04:00
pin.rs Stabilize const_pin_2 2024-11-20 07:54:12 -05:00
primitive.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
primitive_docs.rs Rollup merge of #132136 - RalfJung:target-feature-abi-compat, r=Mark-Simulacrum 2024-11-10 10:09:52 +01:00
random.rs random: add tracking issue, address other comments 2024-09-23 10:36:16 +02:00
range.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
result.rs rustdoc-search: simplify rules for generics and type params 2024-10-30 12:27:48 -07:00
time.rs get rid of a whole bunch of unnecessary rustc_const_unstable attributes 2024-11-02 09:59:55 +01:00
tuple.rs update cfgs 2024-09-05 17:24:01 +01:00
ub_checks.rs clean up const stability around UB checks 2024-11-16 22:50:22 +01:00
unit.rs Import the 2021 prelude in the core crate 2024-03-25 13:12:06 -07:00