rust/compiler/rustc_span/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
..
analyze_source_file remove redundant closures (clippy::redundant_closure) 2021-01-03 13:34:24 +01:00
edit_distance Add test for precise algorithm used 2023-02-19 22:59:22 +00:00
source_map Auto merge of #106810 - oli-obk:resolver_reverse_plumbing, r=petrochenkov 2023-01-19 05:23:40 +00:00
symbol Move the Lock into symbol::Interner 2021-09-15 18:46:45 +02:00
analyze_source_file.rs more clippy::complexity fixes 2022-12-15 00:09:10 +01:00
caching_source_map_view.rs Remove useless borrows and derefs 2022-12-01 17:34:43 +00:00
def_id.rs Eagerly intern and check CrateNum/StableCrateId collisions 2023-03-21 12:08:17 +00:00
edit_distance.rs add comment 2023-04-06 06:51:49 +08:00
edition.rs Rename rust_2015 => is_rust_2015 2023-02-02 08:17:13 +00:00
fatal_error.rs Make fatal DiagnosticBuilder yield never 2022-03-27 22:25:32 -07:00
hygiene.rs a couple clippy::complexity fixes 2023-04-01 23:16:33 +02:00
lib.rs Remove a fishy Clone impl 2023-04-04 09:01:44 +00:00
profiling.rs Remove an unnecessary use of with_session_globals. 2023-03-31 15:34:00 +11:00
source_map.rs Implementing "<test_binary> --list --format json" #107307 #49359 2023-03-15 14:20:20 -04:00
span_encoding.rs Intern span when length is MAX_LEN with parent. 2023-02-11 17:46:22 +00:00
symbol.rs Auto merge of #106281 - JulianKnodt:transmute_const_generics, r=b-naber 2023-04-08 19:47:22 +00:00
tests.rs Lazify SourceFile::lines. 2022-06-01 10:36:39 +10:00