-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: 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.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This issue collect various proposals for improvements to the MIR sanity check so that they do not get lost:
- Function calls and
DropAndReplace
could test that given and expected type match (MIR sanity check: validate types on assignment #72796 (comment)) SetDiscriminant
could have some invariants checked (MIR sanity check: validate types on assignment #72796 (comment))
Metadata
Metadata
Assignees
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: 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.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
RalfJung commentedon Jun 28, 2020
@oli-obk re:
SetDiscriminant
, allowing that only for enums seems curiously asymmetric withGetDiscriminant
which works for all ADTs.oli-obk commentedon 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 commentedon Jun 28, 2020
Actually, does
GetDiscriminant
only work for ADTs or for all types? I forgot.oli-obk commentedon 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 commentedon Jun 28, 2020
Rvalue::Discriminant
is also used forTyKind::Generator
s. edit: Whoops, this was already mentioned.RalfJung commentedon Jun 28, 2020
MIR building creates it for every
match
I think... or was it just everymatch
of an ADT?