Pre-RFC: sum-enums

I’ll point out that using ascription patterns is incompatible with how ascription patterns are used today. It is not clear that x: T asserts that x is a T or that x is the variant of type T. Moreover, the following code’s behavior has been left undefined:

fn foo<T, U>(x: enum(T, U)) {
  match x {
    t: T => panic!("T"),
    u: U => panic!("U"),
  }
}

foo::<i32, i32>(x)

The only solution to this problem is to somehow ban that monomorphization or to ban generic anonymous sums (or, to introduce where T != U clauses, which is overkill).

5 Likes