You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spec: §4.4a ("Discriminant enums with payloads: Variants can carry associated data just like regular enums, combined with explicit discriminant values"; the layout is { repr_ty, [max_payload_size x i8] } "with the tag being the discriminant value").
A payload-carrying discriminant enum whose discriminants are not 0, 1, 2, … fails code generation:
enum Msg: i32:
Quit = 0
Move(i32, i32) = 7
fn main:
let m = Msg.Move(1, 2)
match m:
.Quit => print("q")
.Move(x, y) => print(x + y)
The discriminant value (7) is used where the variant index (1) is expected when the aggregate's payload type is looked up. The same with u8 repr and Write(str) = 200. With discriminants 0, 1, 2 it works.
Expected: prints 3.
Found while exhausting the #1444 matrix (stage1 of origin/main 1c76062).
Activity
MIR/codegen: a discriminant enum's discriminant is a value of its rep…
MIR/codegen: a discriminant enum's discriminant is a value of its rep…
MIR/codegen: an enum aggregate names its variant by index; the tag it…
MIR/codegen: an enum aggregate names its variant by index; the tag it…
ehartford commentedon Sep 26, 2026
Verified fixed on main 55739d4 (release binary): payload discriminant enum matches, prints 3.