Explicit match on uninhabited type shouldn't warn #55116
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
So say I have a function that takes an uninhabited type (common e.g. when implementing a trait for
!
). I would like to make it explicit that I am using "ex falso quod libet" reasoning, so I writeUnfortunately, now Rust warns:
It seems it wants me to instead write
I think that's bad style, now I have to think much harder to figure out what is going on ("oh, there's a coercion from uninhabited types to
bool
"). The original code I wrote uses a construct which only works for uninhabited types, explicitly documenting intent.I think the compiler should not print a warning for that code. Empty matches are a useful, explicit and constructive way of saying that we are dealing with uninhabited data, we shouldn't discourage them in favor of implicit coercions that require way more context to comprehend.
The text was updated successfully, but these errors were encountered: