Skip to content

[MIR] Cannot explicitly set discriminant #35186

Closed
@scottcarr

Description

@scottcarr

In #35168, we might like to deaggregate enums like:

x = Foo::Bar{a: 0, b: 0};

Into:

(x as Foo::Bar).0 = 0;
(x as Foo:Bar).1 = 0;

The problem (as far I know) is that the deaggregated version never sets the discrimnant.

I had some code that at least did the casting:

// if we handled enums:
let lhs_cast = if adt_def.variants.len() > 1 {
     Lvalue::Projection(Box::new(LvalueProjection {
         base: ai.lhs.clone(),
         elem: ProjectionElem::Downcast(ai.adt_def, ai.variant),
     }))
 } else {
     lhs_cast
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions