Files
rust/library
Jonathan Brouwer 9e9dc37b47 Rollup merge of #160860 - maxdexh:custom-mir-casts, r=oli-obk
Implement arbitrary casts in custom mir

[See zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/extending.20custom.20MIR/with/613727602)

Implement custom casts using an enum in `intrinsics::mir` that closely matches the `CastKind` enum in the compiler.

We have 5 different ways to cast in custom MIR, 3 with functions (which hard code a cast kind), 1 implicit coerce (which only does subtyping i think), 1 with `as` (which does a few more). They are all different and the error messages don't tell you what to do. Some are (i think) not possible at all.

This came up [while testing miri](https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/Valdity.20checks.20for.20references/near/613662285). We currently have to guess the casting syntax until we find the one that generates the MIR we want. This PR changes that by adding a custom mir operation that allows picking an arbitrary cast.

r? RalfJung
2026-09-11 12:45:03 +02:00
..
2026-08-19 09:27:38 -07:00
2026-08-25 18:15:16 +00:00