[rust-dev] Heads up: alt expressions must now be exhaustive

Tim Chevalier catamorphism at gmail.com
Tue Jan 31 10:11:57 PST 2012


I've just committed a change that requires alt expressions in Rust to
be exhaustive. The change only applies to alts on expressions of type
enum, where the patterns are either irrefutable patterns or
constructor patterns. So for example:

enum foo { a, b }

let x:foo = ...; alt x { a { ...} }

will no longer compile.

If you write a non-exhaustive alt (on an enum-typed expression) that
the compiler accepts, that's a bug, so please report it.

Some languages (e.g. Haskell) make this a warning rather than an
error, but after discussion, the Rust team has decided to make it an


Tim Chevalier * http://catamorphism.org/ * Often in error, never in doubt
“I cannot hide my anger to spare you guilt, nor hurt feelings, nor
answering anger; for to do so insults and trivializes all our efforts.
Guilt is not a response to anger; it is a response to one’s own
actions or lack of action.” -- Audre Lorde

More information about the Rust-dev mailing list