Description
The compiler has a type to represent integer values of arbitrary size and sign: ScalarInt. It comes with a bunch of useful helpers and is used throughout the interpreter, CTFE, and valtrees.
However, The SwitchInt terminator stores the variants as u128
rather than a ScalarInt. I think this is mostly for historical reasons, it is older than ScalarInt. However ScalarInt is also 1 byte bigger than u128 due to a size that is stored, largely as sanity check.
I think ideally we'd change SwitchTarget to use ScalarInt. If the extra byte per arm is too much (in fact it might be more, SmallVec is ptr-aligned so it will probably add padding), then alternatively we could add APIs to SwitchTarget that let one work with it as-if it was a ScalarInt, hiding the u128 from sight.
Cc @rust-lang/wg-mir-opt