about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/errors.rs
diff options
context:
space:
mode:
authorDavid Rheinsberg <david@readahead.eu>2023-07-24 14:11:26 +0200
committerDavid Rheinsberg <david@readahead.eu>2024-03-20 10:58:43 +0100
commit31d23c436aabdb6509f39f09681011176add3da1 (patch)
tree5a82ba6cacdfa489a284e8d2b134280d6bff092d /compiler/rustc_codegen_llvm/src/errors.rs
parentb7dcabe55e3b915ba9488dc374f752404c2c8945 (diff)
downloadrust-31d23c436aabdb6509f39f09681011176add3da1.tar.gz
rust-31d23c436aabdb6509f39f09681011176add3da1.zip
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.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
0 files changed, 0 insertions, 0 deletions