# Enum Size Opt MirPass For all variables & temporaries in the MirPass: If its type is not an enum, ignore it. Otherwise, check if there's a "large enough" discrepancy between the enum variant sizes. If there is, find all `Assign` where the lhs (not the local, but the entire projection in case of `_x.foo[42]`) is of the enum type. ```rust _x.foo = _y.bar // rhs is `Operand` ``` ```rust StorageLive(new_local) // This is the tricky bit since it has to be runtime memory? new_local = const &[size_1, size_2, ...]; ``` This constant is a reference to an array of all variants' sizes. Then find the size of the current variant: ```rust discr = discriminant(_y.bar) size = new_local[discr] ``` Then replace `_x.foo = _y.bar` with ```rust _x1 = &_x.foo as *const _ _y1 = &_y.bar as *const _ copy_nonverlapping(_x1, _y1, 1) ``` Based on [this comment](https://github.com/rust-lang/rust/issues/54360#issuecomment-422924534).