Skip to content
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

MIR sanity check improvements #73832

Open
RalfJung opened this issue Jun 28, 2020 · 6 comments
Open

MIR sanity check improvements #73832

RalfJung opened this issue Jun 28, 2020 · 6 comments
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

This issue collect various proposals for improvements to the MIR sanity check so that they do not get lost:

@RalfJung
Copy link
Member Author

@oli-obk re: SetDiscriminant, allowing that only for enums seems curiously asymmetric with GetDiscriminant which works for all ADTs.

@RalfJung RalfJung added the A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html label Jun 28, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Jun 28, 2020

Right, so let's check that the local is an Adt and that the discriminant id is actually a valid id for that type.

@RalfJung
Copy link
Member Author

RalfJung commented Jun 28, 2020

Actually, does GetDiscriminant only work for ADTs or for all types? I forgot.

@oli-obk
Copy link
Contributor

oli-obk commented Jun 28, 2020

It works for all types (returning 0 for things that are neither Adt nor generator). That doesn't mean MIR building ever creates it and I don't think I've seen it before.

@ecstatic-morse
Copy link
Contributor

ecstatic-morse commented Jun 28, 2020

Rvalue::Discriminant is also used for TyKind::Generators. edit: Whoops, this was already mentioned.

@RalfJung
Copy link
Member Author

It works for all types (returning 0 for things that are neither Adt nor generator). That doesn't mean MIR building ever creates it and I don't think I've seen it before.

MIR building creates it for every match I think... or was it just every match of an ADT?

@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants