rust/compiler/rustc_middle/src
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
..
dep_graph Hide warning. 2023-04-03 15:59:21 +00:00
hir Update ty::VariantDef to use IndexVec<FieldIdx, FieldDef> 2023-03-30 09:23:40 -07:00
infer Remove index from BrAnon 2023-04-06 23:01:40 -04:00
middle fix clippy::iter_kv_map 2023-04-01 23:44:16 +02:00
mir Auto merge of #110036 - jackh726:placeholder_boundvar, r=nnethercote 2023-04-07 14:26:24 +00:00
query Auto merge of #109333 - Zoxc:erase-query-cache-values, r=cjgillot 2023-04-06 16:29:36 +00:00
thir Add Span to StmtKind::Let. 2023-04-03 15:59:21 +00:00
traits Tweak debug outputs to make debugging new solver easier 2023-04-05 03:18:29 +00:00
ty Auto merge of #106281 - JulianKnodt:transmute_const_generics, r=b-naber 2023-04-08 19:47:22 +00:00
util Add some docs to bug, span_bug and delay_span_bug 2022-12-30 16:47:56 +01:00
arena.rs rustc_interface: Add a new query pre_configure 2023-03-23 14:22:48 +04:00
error.rs fix(middle): emit error rather than delay bug when reaching limit 2023-04-03 11:08:14 +08:00
lib.rs Avoid the assertion in erase 2023-04-06 08:25:53 +02:00
lint.rs create helper function for rustc_lint_defs::Level and remove it's duplicated code r=ozkanonur 2023-01-10 10:56:17 +03:00
macros.rs Remove type-traversal trait aliases 2023-02-22 17:04:58 +00:00
metadata.rs rustc: Parameterize ty::Visibility over used ID 2022-09-07 13:35:41 +04:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
thir.rs Add Span to StmtKind::Let. 2023-04-03 15:59:21 +00:00
values.rs rustc_middle: Remove trait DefIdTree 2023-03-02 23:46:44 +04:00