rust/compiler
bors af06dce64b Auto merge of #106281 - JulianKnodt:transmute_const_generics, r=b-naber
Add ability to transmute (somewhat) with generic consts in arrays

Previously if the expression contained generic consts and did not have a directly equivalent type, transmuting the type in this way was forbidden, despite the two sizes being identical. Instead, we should be able to lazily tell if the two consts are identical, and if so allow them to be transmuted.

This is done by normalizing the forms of expressions into sorted order of multiplied terms, which is not generic over all expressions, but should handle most cases.

This allows for some _basic_ transmutations between types that are equivalent in size without requiring additional stack space at runtime.

I only see one other location at which `SizeSkeleton` is being used, and it checks for equality so this shouldn't affect anywhere else that I can tell.

See [this Stackoverflow post](https://stackoverflow.com/questions/73085012/transmute-nested-const-generic-array-rust) for what was previously necessary to convert between types. This PR makes converting nested `T -> [T; 1]` transmutes possible, and `[uB*2; N] -> [uB; N * 2]` possible as well.

I'm not sure whether this is something that would be wanted, and if it is it definitely should not be insta-stable, so I'd add a feature gate.
2023-04-08 19:47:22 +00:00
..
rustc fix link 2023-03-11 10:53:47 -06:00
rustc_abi Use FieldIdx in FieldsShape 2023-04-04 12:38:06 -07:00
rustc_apfloat compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
rustc_arena compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
rustc_ast Rename ast::Static to ast::StaticItem to match ast::ConstItem 2023-04-04 15:34:40 +00:00
rustc_ast_lowering Rename ast::Static to ast::StaticItem to match ast::ConstItem 2023-04-04 15:34:40 +00:00
rustc_ast_passes Rollup merge of #109914 - compiler-errors:rtn-bad-parens, r=oli-obk 2023-04-04 09:27:46 -07:00
rustc_ast_pretty Rename ast::Static to ast::StaticItem to match ast::ConstItem 2023-04-04 15:34:40 +00:00
rustc_attr Bless tidy 2023-03-27 18:58:07 +00:00
rustc_baked_icu_data update ICU4X to 1.1.0 2023-02-04 22:28:59 +01:00
rustc_borrowck Auto merge of #110036 - jackh726:placeholder_boundvar, r=nnethercote 2023-04-07 14:26:24 +00:00
rustc_builtin_macros Stabilize is_some_and 2023-04-06 23:14:23 +02:00
rustc_codegen_cranelift Rename Abort terminator to Terminate 2023-04-06 09:34:16 +01:00
rustc_codegen_gcc Update gccjit and remove libc 0.1 dependency 2023-03-30 18:30:56 +02:00
rustc_codegen_llvm Auto merge of #109862 - klensy:llvm-dd, r=nikic 2023-04-08 15:57:59 +00:00
rustc_codegen_ssa Auto merge of #109971 - WaffleLapkin:yeet_ownership, r=Nilstrieb 2023-04-08 01:08:26 +00:00
rustc_const_eval Auto merge of #102906 - nbdd0121:mir, r=wesleywiser,tmiasko 2023-04-07 10:31:14 +00:00
rustc_data_structures Auto merge of #109971 - WaffleLapkin:yeet_ownership, r=Nilstrieb 2023-04-08 01:08:26 +00:00
rustc_driver Remove unneeded extern crate 2023-02-02 07:47:39 +01:00
rustc_driver_impl implement --print=all-target-specs-json 2023-04-03 09:24:14 +02:00
rustc_error_codes Rollup merge of #109565 - WaffleLapkin:better_docs_for_e0223, r=oli-obk 2023-03-28 07:01:08 +02:00
rustc_error_messages Stabilize a portion of 'once_cell' 2023-03-29 18:04:44 -04:00
rustc_errors a couple clippy::complexity fixes 2023-04-01 23:16:33 +02:00
rustc_expand Rename ast::Static to ast::StaticItem to match ast::ConstItem 2023-04-04 15:34:40 +00:00
rustc_feature Auto merge of #106281 - JulianKnodt:transmute_const_generics, r=b-naber 2023-04-08 19:47:22 +00:00
rustc_fs_util Add try_canonicalize to rustc_fs_util and use it over fs::canonicalize 2023-03-16 21:50:23 +01:00
rustc_graphviz Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_hir Perform match checking on THIR. 2023-04-03 15:59:21 +00:00
rustc_hir_analysis Auto merge of #110036 - jackh726:placeholder_boundvar, r=nnethercote 2023-04-07 14:26:24 +00:00
rustc_hir_pretty Add (..) syntax for RTN 2023-03-28 01:14:28 +00:00
rustc_hir_typeck Auto merge of #106281 - JulianKnodt:transmute_const_generics, r=b-naber 2023-04-08 19:47:22 +00:00
rustc_incremental Check for escape sequences in Fluent resources 2023-03-29 18:34:29 +01:00
rustc_index Auto merge of #109915 - scottmcm:layout-indexvec, r=oli-obk 2023-04-06 07:38:58 +00:00
rustc_infer Auto merge of #110043 - ickk:fix_infer_message, r=eholk 2023-04-08 03:26:54 +00:00
rustc_interface Auto merge of #108504 - cjgillot:thir-pattern, r=compiler-errors,Nilstrieb 2023-04-06 12:42:01 +00:00
rustc_lexer fix(lexer): not skipped whitespace warning for '\x0c' 2023-03-09 22:44:58 +08:00
rustc_lint Auto merge of #109117 - oli-obk:locks, r=michaelwoerister 2023-04-05 10:38:02 +00:00
rustc_lint_defs Rollup merge of #108588 - ehuss:lint-docs-produces, r=eholk 2023-03-23 19:55:45 +01:00
rustc_llvm Auto merge of #109862 - klensy:llvm-dd, r=nikic 2023-04-08 15:57:59 +00:00
rustc_log write threads info into log only when debugging 2023-04-04 15:31:37 +08:00
rustc_macros address comments 2023-04-06 04:55:58 +00:00
rustc_metadata Auto merge of #109971 - WaffleLapkin:yeet_ownership, r=Nilstrieb 2023-04-08 01:08:26 +00:00
rustc_middle Auto merge of #106281 - JulianKnodt:transmute_const_generics, r=b-naber 2023-04-08 19:47:22 +00:00
rustc_mir_build Auto merge of #102906 - nbdd0121:mir, r=wesleywiser,tmiasko 2023-04-07 10:31:14 +00:00
rustc_mir_dataflow Revert box_free unwind action 2023-04-06 09:34:16 +01:00
rustc_mir_transform Auto merge of #102906 - nbdd0121:mir, r=wesleywiser,tmiasko 2023-04-07 10:31:14 +00:00
rustc_monomorphize Rename Abort terminator to Terminate 2023-04-06 09:34:16 +01:00
rustc_parse fix: fix regression in #109203 2023-04-07 08:54:13 +12:00
rustc_parse_format Improve heuristics for format_args literal being suggestable 2023-03-14 13:20:39 +00:00
rustc_passes Replace a lock with an atomic 2023-04-04 09:01:44 +00:00
rustc_plugin_impl expand: Pass ast::Crate by reference to AST transforming passes 2023-03-23 14:20:55 +04:00
rustc_privacy Auto merge of #109762 - scottmcm:variantdef-indexvec, r=WaffleLapkin 2023-03-31 03:36:18 +00:00
rustc_query_impl Auto merge of #110012 - matthiaskrgr:rollup-sgmm5xv, r=matthiaskrgr 2023-04-06 18:48:42 +00:00
rustc_query_system Address comments 2023-04-06 08:25:53 +02:00
rustc_resolve Use smart-resolve when checking for trait in RHS of UFCS 2023-04-07 05:33:52 +00:00
rustc_serialize Remove f32 & f64 from MemDecoder/MemEncoder 2023-04-06 00:54:07 -07:00
rustc_session Auto merge of #108905 - ferrocene:pa-compiletest-ignore, r=ehuss 2023-04-05 16:15:25 +00:00
rustc_smir Fix new usage of old api 2023-04-06 09:34:16 +01:00
rustc_span Auto merge of #106281 - JulianKnodt:transmute_const_generics, r=b-naber 2023-04-08 19:47:22 +00:00
rustc_symbol_mangling Remove index from BrAnon 2023-04-06 23:01:40 -04:00
rustc_target Disable has_thread_local on OpenHarmony 2023-04-04 02:42:42 +01:00
rustc_trait_selection Switched provisional evaluation cache map to FxIndexMap, and replaced map.drain_filter with map.retain 2023-04-07 19:41:08 -04:00
rustc_traits Remove u32 on BoundTyKind::Anon 2023-04-06 23:08:04 -04:00
rustc_transmute rustc_middle: Remove trait DefIdTree 2023-03-02 23:46:44 +04:00
rustc_ty_utils Use FieldIdx in FieldsShape 2023-04-04 12:38:06 -07:00
rustc_type_ir Generate simpler MIR for shifts 2023-03-22 13:32:12 -07:00