Implement arbitrary casts in custom mir - #160860
Draft
maxdexh wants to merge 2 commits into
Draft
Conversation
Collaborator
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
maxdexh
force-pushed
the
custom-mir-casts
branch
from
August 10, 2026 16:26
bb0a712 to
a596f67
Compare
Member
|
I am on vacation this week, so this will have to wait a bit. Or maybe @saethlin has time to look at it earlier. |
Contributor
Author
|
This is not done yet anyway, I still gotta figure out how to unflatten the enum and write some tests. But thanks for letting me know :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See zulip
Implement custom casts using an enum in
intrinsics::mirthat closely matches theCastKindenum 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. We currently have to guess the casting syntax until we find the one that generates the MIR we want. This PR changes that by allowing you to just pick.
The
intrinsics::mir::CastKindis currently a flattened version of the compiler's. If nested enums are possible then I'd like to unflatten it.This is missing tests, still figuring out how those work.
r? RalfJung