rust/tests/ui/transmute
David Rheinsberg 31d23c436a compiler: allow transmute of ZST arrays with generics
Extend the `SizeSkeleton` evaluator to shortcut zero-sized arrays, thus
considering `[T; 0]` to have a compile-time fixed-size of 0.

The existing evaluator already deals with generic arrays under the
feature-guard `transmute_const_generics`. However, it merely allows
comparing fixed-size types with fixed-size types, and generic types with
generic types. For generic types, it merely compares whether their
arguments match (ordering them first). Even if their exact sizes are not
known at compile time, it can ensure that they will eventually be the
same.

This patch extends this by shortcutting the size-evaluation of zero
sized arrays and thus allowing size comparisons of `()` with `[T; 0]`,
where one contains generics and the other does not.

This code is guarded by `transmute_const_generics` (#109929), even
though it is unclear whether it should be. However, this assumes that a
separate stabilization PR is required to move this out of the feature
guard.

Initially reported in #98104.
2024-03-20 10:58:43 +01:00
..
lifetimes.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
main.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
main.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-different-sizes.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
transmute-different-sizes.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-fat-pointers.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
transmute-fat-pointers.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-from-fn-item-types-error.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-from-fn-item-types-error.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-impl.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
transmute-impl.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
transmute-imut-to-mut.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-imut-to-mut.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
transmute-type-parameters.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-type-parameters.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-zst-generics.rs compiler: allow transmute of ZST arrays with generics 2024-03-20 10:58:43 +01:00