Skip to content

MIR sanity check improvements #73832

@RalfJung

Description

@RalfJung
Member

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

Activity

RalfJung

RalfJung commented on Jun 28, 2020

@RalfJung
MemberAuthor

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

added
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
on Jun 28, 2020
oli-obk

oli-obk commented on Jun 28, 2020

@oli-obk
Contributor

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

RalfJung commented on Jun 28, 2020

@RalfJung
MemberAuthor

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

oli-obk

oli-obk commented on Jun 28, 2020

@oli-obk
Contributor

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

ecstatic-morse commented on Jun 28, 2020

@ecstatic-morse
Contributor

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

RalfJung

RalfJung commented on Jun 28, 2020

@RalfJung
MemberAuthor

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?

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @RalfJung@oli-obk@ecstatic-morse@Noratrieb

        Issue actions

          MIR sanity check improvements · Issue #73832 · rust-lang/rust