rust/compiler
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
..
rustc
rustc_abi Auto merge of #121668 - erikdesjardins:commonprim, r=scottmcm,oli-obk 2024-03-13 15:25:35 +00:00
rustc_arena rename ptr::invalid -> ptr::without_provenance 2024-02-21 20:15:52 +01:00
rustc_ast Auto merge of #122055 - compiler-errors:stabilize-atb, r=oli-obk 2024-03-19 00:04:09 +00:00
rustc_ast_ir Fix typo in VisitorResult 2024-03-08 23:20:29 -05:00
rustc_ast_lowering The AssocOpaqueTy HIR node is not actually needed to differentiate from other hir nodes that were fed 2024-03-19 08:37:53 +00:00
rustc_ast_passes Auto merge of #122055 - compiler-errors:stabilize-atb, r=oli-obk 2024-03-19 00:04:09 +00:00
rustc_ast_pretty Rename ast::StmtKind::Local into ast::StmtKind::Let 2024-03-14 12:42:04 +01:00
rustc_attr Rename IntoDiagnostic as Diagnostic. 2024-03-11 09:15:09 +11:00
rustc_baked_icu_data
rustc_borrowck Auto merge of #116935 - oli-obk:different_lifetime_taits_in_same_sig, r=compiler-errors 2024-03-19 19:57:51 +00:00
rustc_builtin_macros delay expand macro bang when there has indeterminate path 2024-03-13 16:11:16 +08:00
rustc_codegen_cranelift Make ptr_guaranteed_cmp a rustc_intrinsic and favor its body over backends implementing it 2024-03-19 09:17:40 +00:00
rustc_codegen_gcc Auto merge of #122055 - compiler-errors:stabilize-atb, r=oli-obk 2024-03-19 00:04:09 +00:00
rustc_codegen_llvm Rollup merge of #122649 - cuviper:min-llvm-17, r=nikic 2024-03-18 16:27:09 +01:00
rustc_codegen_ssa Rollup merge of #122691 - veera-sivarajan:bugfix-121099, r=Amanieu 2024-03-19 18:03:51 +01:00
rustc_const_eval Ensure nested statics have a HIR node to prevent various queries from ICEing 2024-03-19 09:38:15 +00:00
rustc_data_structures Issue 122262: MAP_PRIVATE for more reliability on virtualised filesystems. 2024-03-15 18:31:07 -04:00
rustc_driver
rustc_driver_impl Rollup merge of #121764 - Zoxc:incr-sess-no-source, r=oli-obk 2024-03-14 20:00:18 +01:00
rustc_error_codes Auto merge of #122055 - compiler-errors:stabilize-atb, r=oli-obk 2024-03-19 00:04:09 +00:00
rustc_error_messages Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_errors When displaying multispans, ignore empty lines adjacent to ... 2024-03-18 16:25:36 +00:00
rustc_expand Auto merge of #122029 - estebank:drive-by-ui-test, r=oli-obk 2024-03-19 22:11:59 +00:00
rustc_feature Rollup merge of #122695 - surechen:make_only_local_explict_argument, r=lcnr 2024-03-19 18:03:52 +01:00
rustc_fluent_macro Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_fs_util Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_graphviz Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_hir Rollup merge of #122719 - oli-obk:nested_static_feed_hir, r=fee1-dead 2024-03-19 18:03:53 +01:00
rustc_hir_analysis Rollup merge of #122719 - oli-obk:nested_static_feed_hir, r=fee1-dead 2024-03-19 18:03:53 +01:00
rustc_hir_pretty The AssocOpaqueTy HIR node is not actually needed to differentiate from other hir nodes that were fed 2024-03-19 08:37:53 +00:00
rustc_hir_typeck Auto merge of #122119 - estebank:issue-117846, r=Nadrieril 2024-03-20 02:36:37 +00:00
rustc_incremental Make incremental sessions identity no longer depend on the crate names provided by source code 2024-03-13 16:40:02 +01:00
rustc_index doc: Add better explanation 2024-03-06 16:54:42 +01:00
rustc_index_macros Step all bootstrap cfgs forward 2024-02-08 07:44:34 -05:00
rustc_infer Auto merge of #122735 - matthiaskrgr:rollup-pgb1s90, r=matthiaskrgr 2024-03-19 17:52:46 +00:00
rustc_interface Rollup merge of #121764 - Zoxc:incr-sess-no-source, r=oli-obk 2024-03-14 20:00:18 +01:00
rustc_lexer Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_lint The AssocOpaqueTy HIR node is not actually needed to differentiate from other hir nodes that were fed 2024-03-19 08:37:53 +00:00
rustc_lint_defs Rollup merge of #121720 - tmandry:split-refining, r=compiler-errors 2024-03-16 23:28:47 +01:00
rustc_llvm Update the minimum external LLVM to 17 2024-03-17 10:11:04 -07:00
rustc_log rustc_log: expose tracing-tree "wraparound" in an env var 2024-03-03 12:33:26 +01:00
rustc_macros Rename diagnostic derive things. 2024-03-11 10:06:34 +11:00
rustc_metadata Rollup merge of #122695 - surechen:make_only_local_explict_argument, r=lcnr 2024-03-19 18:03:52 +01:00
rustc_middle compiler: allow transmute of ZST arrays with generics 2024-03-20 10:58:43 +01:00
rustc_mir_build Remove all checks of IntrinsicDef::must_be_overridden except for the actual overrides in codegen 2024-03-19 09:19:58 +00:00
rustc_mir_dataflow Distinguish between library and lang UB in assert_unsafe_precondition 2024-03-08 18:53:58 -05:00
rustc_mir_transform Auto merge of #122037 - oli-obk:more_new_intrinsics, r=Nilstrieb 2024-03-19 13:10:01 +00:00
rustc_monomorphize Remove all checks of IntrinsicDef::must_be_overridden except for the actual overrides in codegen 2024-03-19 09:19:58 +00:00
rustc_next_trait_solver Allow a way to add constructors for rustc_type_ir types 2024-03-04 15:39:59 +00:00
rustc_parse Rollup merge of #122717 - workingjubilee:handle-call-call-call-call-calling-me-maybe, r=compiler-errors 2024-03-19 18:03:52 +01:00
rustc_parse_format Extend format arg help for simple tuple index access expression 2024-03-16 22:33:02 +00:00
rustc_passes Rollup merge of #122719 - oli-obk:nested_static_feed_hir, r=fee1-dead 2024-03-19 18:03:53 +01:00
rustc_pattern_analysis Rollup merge of #121823 - Nadrieril:never-witnesses, r=compiler-errors 2024-03-18 22:24:36 +01:00
rustc_privacy Test and implement reachability for trait objects and generic parameters of functions 2024-03-14 14:10:45 +00:00
rustc_query_impl Verify that query keys result in unique dep nodes 2024-03-12 05:31:41 +01:00
rustc_query_system Rollup merge of #122245 - saethlin:check-dep-graph-size, r=petrochenkov 2024-03-12 09:04:00 -07:00
rustc_resolve Rollup merge of #122435 - jieyouxu:unused_qualifications_global_paths, r=petrochenkov 2024-03-19 18:03:49 +01:00
rustc_serialize Stabilize associated type bounds 2024-03-08 20:56:25 +00:00
rustc_session Rollup merge of #122158 - estebank:feature-sugg, r=WaffleLapkin 2024-03-18 22:24:38 +01:00
rustc_smir 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
rustc_span remove retag_box_to_raw, it is no longer needed 2024-03-18 10:32:25 +01:00
rustc_symbol_mangling Rename IntoDiagnostic as Diagnostic. 2024-03-11 09:15:09 +11:00
rustc_target Rollup merge of #122212 - erikdesjardins:byval-align2, r=wesleywiser 2024-03-14 20:00:18 +01:00
rustc_trait_selection Auto merge of #122119 - estebank:issue-117846, r=Nadrieril 2024-03-20 02:36:37 +00:00
rustc_traits Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
rustc_transmute 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
rustc_ty_utils Ensure nested statics have a HIR node to prevent various queries from ICEing 2024-03-19 09:38:15 +00:00
rustc_type_ir Auto merge of #122392 - BoxyUwU:misc_cleanup, r=lcnr 2024-03-19 15:38:41 +00:00
stable_mir Rollup merge of #122405 - celinval:smir-new-const, r=oli-obk 2024-03-14 11:09:58 +01:00