rust/tests/ui/abi
bors 86d0aef804 Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk
Sized Hierarchy: Part I

This patch implements the non-const parts of rust-lang/rfcs#3729. It introduces two new traits to the standard library, `MetaSized` and `PointeeSized`. See the RFC for the rationale behind these traits and to discuss whether this change makes sense in the abstract.

These traits are unstable (as is their constness), so users cannot refer to them without opting-in to `feature(sized_hierarchy)`. These traits are not behind `cfg`s as this would make implementation unfeasible, there would simply be too many `cfg`s required to add the necessary bounds everywhere. So, like `Sized`, these traits are automatically implemented by the compiler.

RFC 3729 describes changes which are necessary to preserve backwards compatibility given the introduction of these traits, which are implemented and as follows:

- `?Sized` is rewritten as `MetaSized`
- `MetaSized` is added as a default supertrait for all traits w/out an explicit sizedness supertrait already.

There are no edition migrations implemented in this,  as these are primarily required for the constness parts of the RFC and prior to stabilisation of this (and so will come in follow-up PRs alongside the const parts). All diagnostic output should remain the same (showing `?Sized` even if the compiler sees `MetaSized`) unless the `sized_hierarchy` feature is enabled.

Due to the use of unstable extern types in the standard library and rustc, some bounds in both projects have had to be relaxed already - this is unfortunate but unavoidable so that these extern types can continue to be used where they were before. Performing these relaxations in the standard library and rustc are desirable longer-term anyway, but some bounds are not as relaxed as they ideally would be due to the inability to relax `Deref::Target` (this will be investigated separately).

It is hoped that this is implemented such that it could be merged and these traits could exist "under the hood" without that being observable to the user (other than in any performance impact this has on the compiler, etc). Some details might leak through due to the standard library relaxations, but this has not been observed in test output.

**Notes:**

- Any commits starting with "upstream:" can be ignored, as these correspond to other upstream PRs that this is based on which have yet to be merged.
- This best reviewed commit-by-commit. I've attempted to make the implementation easy to follow and keep similar changes and test output updates together.
  - Each commit has a short description describing its purpose.
  - This patch is large but it's primarily in the test suite.
- I've worked on the performance of this patch and a few optimisations are implemented so that the performance impact is neutral-to-minor.
- `PointeeSized` is a different name from the RFC just to make it more obvious that it is different from `std::ptr::Pointee` but all the names are yet to be bikeshed anyway.
- `@nikomatsakis` has confirmed [that this can proceed as an experiment from the t-lang side](https://rust-lang.zulipchat.com/#narrow/channel/435869-project-goals/topic/SVE.20and.20SME.20on.20AArch64.20.28goals.23270.29/near/506196491)
- FCP in https://github.com/rust-lang/rust/pull/137944#issuecomment-2912207485

Fixes rust-lang/rust#79409.

r? `@ghost` (I'll discuss this with relevant teams to find a reviewer)
2025-06-17 15:08:50 +00:00
..
cross-crate tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
extern tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
foreign tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
issues Update test directives for wasm32-wasip1 2024-03-11 09:36:35 -07:00
mir Update test directives for wasm32-wasip1 2024-03-11 09:36:35 -07:00
numbers-arithmetic Fix RISC-V C function ABI when passing/returning structs containing floats 2025-06-16 10:14:07 +01:00
statics Update tests for hidden references to mutable static 2024-09-13 14:10:56 +03:00
struct-enums Update test directives for wasm32-wasip1 2024-03-11 09:36:35 -07:00
union Update test directives for wasm32-wasip1 2024-03-11 09:36:35 -07:00
abi-sysv64-arg-passing.rs Enable more tests on Windows 2025-02-03 10:39:32 -05:00
abi-sysv64-register-usage.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
abi-typo-unstable.feature_disabled.stderr update/bless tests 2025-04-06 21:41:47 +02:00
abi-typo-unstable.feature_enabled.stderr update/bless tests 2025-04-06 21:41:47 +02:00
abi-typo-unstable.rs update/bless tests 2025-04-06 21:41:47 +02:00
anon-extern-mod.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
arm-unadjusted-intrinsic.rs tests: use minicore more 2025-02-24 09:26:54 +00:00
bad-custom.rs add extern "custom" functions 2025-06-12 20:27:10 +02:00
bad-custom.stderr add extern "custom" functions 2025-06-12 20:27:10 +02:00
c-stack-as-value.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
c-stack-returning-int64.rs Use the rustc_private libc less in tests 2024-04-15 08:54:11 -04:00
c-zst.aarch64-darwin.stderr Remove rustc's notion of "preferred" alignment AKA __alignof 2025-06-08 16:41:46 -07:00
c-zst.powerpc-linux.stderr Remove rustc's notion of "preferred" alignment AKA __alignof 2025-06-08 16:41:46 -07:00
c-zst.rs use add-core-stubs / minicore for a few more tests 2025-02-16 18:37:50 +01:00
c-zst.s390x-linux.stderr Remove rustc's notion of "preferred" alignment AKA __alignof 2025-06-08 16:41:46 -07:00
c-zst.sparc64-linux.stderr Remove rustc's notion of "preferred" alignment AKA __alignof 2025-06-08 16:41:46 -07:00
c-zst.x86_64-linux.stderr Remove rustc's notion of "preferred" alignment AKA __alignof 2025-06-08 16:41:46 -07:00
c-zst.x86_64-pc-windows-gnu.stderr Remove rustc's notion of "preferred" alignment AKA __alignof 2025-06-08 16:41:46 -07:00
cabi-int-widening.rs Update test directives for wasm32-wasip1 2024-03-11 09:36:35 -07:00
compatibility.rs Remove redundant min-llvm-version annotations for LoongArch tests 2025-05-01 08:50:14 +08:00
custom.rs add extern "custom" functions 2025-06-12 20:27:10 +02:00
debug.rs Replace infallible name_or_empty methods with fallible name methods. 2025-04-17 09:50:52 +10:00
debug.stderr Remove rustc's notion of "preferred" alignment AKA __alignof 2025-06-08 16:41:46 -07:00
explicit_repr_rust.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
fixed_x18.rs tests: {Meta,Pointee}Sized in non-minicore tests 2025-06-16 23:04:33 +00:00
homogenous-floats-target-feature-mixup.rs Remove uses of #[feature(avx512_target_feature)] 2025-05-18 11:12:25 +05:30
issue-28676.rs Update test directives for wasm32-wasip1 2024-03-11 09:36:35 -07:00
large-byval-align.rs Update the minimum external LLVM to 19 2025-04-05 11:44:38 -07:00
nullable-pointer-ffi-compat.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
relocation_model_pic.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
riscv-discoverability-guidance.riscv32.stderr Rollup merge of #137771 - estebank:abi-sugg, r=compiler-errors 2025-03-01 05:49:56 +01:00
riscv-discoverability-guidance.riscv64.stderr Rollup merge of #137771 - estebank:abi-sugg, r=compiler-errors 2025-03-01 05:49:56 +01:00
riscv-discoverability-guidance.rs tests: use minicore more 2025-02-24 09:26:54 +00:00
rust-cold-works-with-rustic-args.rs compiler: use is_rustic_abi in ty_utils 2025-03-04 19:57:51 -08:00
rustcall-generic.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
segfault-no-out-of-stack.rs Insert null checks for pointer dereferences when debug assertions are enabled 2025-01-31 11:13:34 +00:00
shadow-call-stack-without-fixed-x18.rs tests: {Meta,Pointee}Sized in non-minicore tests 2025-06-16 23:04:33 +00:00
simd-abi-checks-avx.rs Remove uses of #[feature(avx512_target_feature)] 2025-05-18 11:12:25 +05:30
simd-abi-checks-avx.stderr Remove uses of #[feature(avx512_target_feature)] 2025-05-18 11:12:25 +05:30
simd-abi-checks-empty-list.rs make abi_unsupported_vector_types a hard error 2025-04-20 11:34:56 +02:00
simd-abi-checks-empty-list.stderr make abi_unsupported_vector_types a hard error 2025-04-20 11:34:56 +02:00
simd-abi-checks-s390x.rs make abi_unsupported_vector_types a hard error 2025-04-20 11:34:56 +02:00
simd-abi-checks-s390x.z10.stderr make abi_unsupported_vector_types a hard error 2025-04-20 11:34:56 +02:00
simd-abi-checks-s390x.z13_no_vector.stderr make abi_unsupported_vector_types a hard error 2025-04-20 11:34:56 +02:00
simd-abi-checks-s390x.z13_soft_float.stderr make abi_unsupported_vector_types a hard error 2025-04-20 11:34:56 +02:00
simd-abi-checks-sse.rs make abi_unsupported_vector_types a hard error 2025-04-20 11:34:56 +02:00
simd-abi-checks-sse.stderr make abi_unsupported_vector_types a hard error 2025-04-20 11:34:56 +02:00
sparcv8plus-llvm19.rs tests: use minicore more 2025-02-24 09:26:54 +00:00
sparcv8plus-llvm19.sparc.stderr tests: use minicore more 2025-02-24 09:26:54 +00:00
sparcv8plus-llvm19.sparc_cpu_v9.stderr tests: use minicore more 2025-02-24 09:26:54 +00:00
sparcv8plus-llvm19.sparc_cpu_v9_feature_v8plus.stderr tests: use minicore more 2025-02-24 09:26:54 +00:00
sparcv8plus-llvm19.sparc_feature_v8plus.stderr tests: use minicore more 2025-02-24 09:26:54 +00:00
sparcv8plus-llvm19.sparcv8plus.stderr tests: use minicore more 2025-02-24 09:26:54 +00:00
sparcv8plus.rs tests: use minicore more 2025-02-24 09:26:54 +00:00
sparcv8plus.sparc.stderr tests: use minicore more 2025-02-24 09:26:54 +00:00
sparcv8plus.sparc_cpu_v9.stderr tests: use minicore more 2025-02-24 09:26:54 +00:00
sparcv8plus.sparc_cpu_v9_feature_v8plus.stderr tests: use minicore more 2025-02-24 09:26:54 +00:00
sparcv8plus.sparc_feature_v8plus.stderr tests: use minicore more 2025-02-24 09:26:54 +00:00
sparcv8plus.sparcv8plus.stderr tests: use minicore more 2025-02-24 09:26:54 +00:00
stack-probes-lto.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
stack-probes.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
stack-protector.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
sysv64-zst.rs Remove the -test suffix from normalize directives 2024-12-27 19:58:16 +11:00
sysv64-zst.stderr Remove rustc's notion of "preferred" alignment AKA __alignof 2025-06-08 16:41:46 -07:00
unsized-args-in-c-abi-issues-94223-115845.rs Delete tuple unsizing 2025-02-27 10:26:33 +00:00
unsupported.aarch64.stderr tests: Bless for weaker unsupported_calling_conventions 2025-06-11 09:58:52 -07:00
unsupported.arm.stderr tests: Bless for weaker unsupported_calling_conventions 2025-06-11 09:58:52 -07:00
unsupported.i686.stderr tests: bless unsupported_calling_conventions linting on some fn_ptrs 2025-06-09 15:50:01 -07:00
unsupported.riscv32.stderr tests: Bless for weaker unsupported_calling_conventions 2025-06-11 09:58:52 -07:00
unsupported.riscv64.stderr tests: Bless for weaker unsupported_calling_conventions 2025-06-11 09:58:52 -07:00
unsupported.rs tests: bless unsupported_calling_conventions linting on some fn_ptrs 2025-06-09 15:50:01 -07:00
unsupported.x64.stderr tests: Bless for weaker unsupported_calling_conventions 2025-06-11 09:58:52 -07:00
unsupported.x64_win.stderr tests: Bless for weaker unsupported_calling_conventions 2025-06-11 09:58:52 -07:00
variadic-ffi.rs Allow "C-unwind" fn to have C variadics 2024-06-22 15:14:14 -07:00
vectorcall-abi-checks.rs UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
vectorcall-abi-checks.stderr vectorcall ABI: error if sse2 is not available 2025-02-20 12:40:58 +01:00
x86stdcall.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
x86stdcall2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00