I have a generic type Expr<A, U, B>
that represents a formal expression over the set of atoms A
, with unary operators U
and binary operators B
. In a certain place in my program I have expressions that only use binary operations, so I created a type enum Empty {}
to represent the set of unary operators for those expressions. Unfortunately I cannot ignore the Expr::Unary(op, expr)
arm of match
expressions over such expressions, because the compiler demands I handle a case that cannot exist.
Is there a way to convince the compiler that such values are impossible? I'm trying to keep my usage of panicking macros such as unreachable!()
to a minimum, so grepping for them actually produces meaningful results.
I believe this is one of the things being worked out as part of the !
stuff. As far as I know, you need to do something with an uninhabited value (like match x {}
) to explicitly make the code path divergent.