-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Implement trans for the MIR Switch terminator #30337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
Abc::C => 3, | ||
Abc::D => 4, | ||
Abc::B(_) => 2, | ||
Abc::A(_) => 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need at least a test for the _ =>
case.
@nagisa Fixed nit and added test case for @dotdash I think I fixed this in my last commit. Does that look right to you? |
@wesleywiser @dotdash regarding
Re EDIT: ah, right, it might be a Thinking about that more, |
@nagisa AIUI, the fact that the diverge block can contain an |
@dotdash but all you can really do in that block, really, is having a I’d rather have |
So, it seems to me that perhaps we should just remove |
As far as having a special block for unreachable code, that seems fine, but it seems like something specific to trans, and not necessarily something that needs to be made manifest in the MIR. |
unimplemented!() | ||
mir::Terminator::Switch { ref discr, ref adt_def, ref targets } => { | ||
let adt_ty = bcx.tcx().lookup_item_type(adt_def.did).ty; | ||
let represented_ty = adt::represent_type(bcx.ccx(), adt_ty).clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I don't think you need to call clone()
here, do you?
@nikomatsakis Fixed nits.
Do you want me to work on that in this PR? |
You can leave it as it is currently, however, if you can add a FIXME of some sort to that effect. |
Ok. Should I tidy the branch up too while I'm in there? |
Sure! |
65231f8
to
2b15361
Compare
I've squashed all my changes and rebased against master. |
@bors r+ nice! |
📌 Commit 2b15361 has been approved by |
Fixes #29574