rust/compiler/rustc_middle/src
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
..
dep_graph Reduce exposure of things. 2023-11-16 16:49:22 +11:00
hir Rollup merge of #122719 - oli-obk:nested_static_feed_hir, r=fee1-dead 2024-03-19 18:03:53 +01:00
hooks coverage: Make is_eligible_for_coverage a hook method 2024-03-13 20:43:35 +11:00
infer add comment 2024-02-22 18:54:51 +01:00
middle Rename BuiltinLintDiagnostics as BuiltinLintDiag. 2024-03-05 12:15:10 +11:00
mir Avoid various uses of Option<Span> in favor of using DUMMY_SP in the few cases that used None 2024-03-18 09:34:08 +00:00
query address nits 2024-03-18 22:28:29 +01:00
thir Add asm label support to THIR 2024-02-24 18:49:39 +00:00
traits cleanup + review 2024-03-18 18:13:25 +01:00
ty compiler: allow transmute of ZST arrays with generics 2024-03-20 10:58:43 +01:00
util Make span_bug panic site useful again 2024-03-19 09:19:12 +00:00
arena.rs Create some minimal HIR for associated opaque types 2024-03-13 17:33:09 +03:00
error.rs Rename DiagnosticMessage as DiagMessage. 2024-03-05 12:14:49 +11:00
lib.rs Make span_bug panic site useful again 2024-03-19 09:19:12 +00:00
lint.rs Guard decorate on when not to skip instead 2024-03-17 15:07:22 +00:00
macros.rs Convert TypeVisitor and DefIdVisitor to use VisitorResult 2024-03-05 13:28:15 -05:00
metadata.rs rustc_metadata: Remove Span from ModChild 2023-04-18 17:25:04 +03:00
tests.rs Remove outdated references to librustc_middle. 2024-01-05 16:34:52 +00:00
thir.rs Docs for thir::ExprKind::Use and thir::ExprKind::Let 2024-03-15 13:11:00 +11:00
values.rs make Representability::Infinite carry ErrorGuaranteed 2024-03-14 20:52:13 +01:00