Skip to content

Wrong codegen for a nested enum match with --opt-level > 0 #15793

@ghost

Description

I hit this in my static inlining PR (#15650) but it turns out it's an existing bug in master and it seems bad.

enum NestedEnum {
    First,
    Second,
    Third
}
enum Enum {
    Variant1(bool),
    Variant2(NestedEnum)
}

fn main() {
    std::os::set_exit_status(match Variant2(Third) {
        Variant1(true) => 1i,
        Variant1(false) => 2,
        Variant2(Second) => 3,
        Variant2(Third) => 4,
        Variant2(First) => 5
    });
}

This should exit with code 4 but instead exits with 5. --opt-level 0 is fine. 0.11 is fine as well. Investigating further.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions