Why MIR tries to get the discriminant of a tuple?


#1

By looking at the MIR of the following program

fn main() {
    match (1, 2) {
        (num, den) if den != 0 => true,
        _ => false
    };
}

I see that MIR has a statement

_3 = discriminant(_2);           // bb0[3]: scope 0 at src/main.rs:2:5: 5:6

that tries to read the discriminant of the tuple _2: (i32, i32).

Is there actually a discriminant associated to tuples? Or is it just a meaningless MIR statement, that survived so far because it’s dead code that is not translated to IR?


#2

There is no discriminant for tuples, but the access is still intentional and achieving something (even if it’s a hack):


#3

I see, thanks!