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
At the moment, if an enum variant changes name, match arms containing it silently become wildcard matches. For example, the following:
enum Foo {
Bar,
Baz,
Quux
}
match f {
Bar => ...,
Baz => ...
Quux => ...
}
will silently have the second arm becoming a wildcard arm if the original enum is changed (instead of a compile error which usually is how you can track down uses of a renamed identifier). In some cases we may get an "unreachable pattern" error, but not always.
I'm proposing we add a lint to warn against arms which are a single identifier bound to a variable instead of a variant. Instead, we suggest that _ @ variable arms are used.
This doesn't handle patterns where enums are nested, i.e Some(Bar) when Bar gets renamed. If we want to catch these too we might want to instead lint uppercase PatIdents anywhere in a match where the corresponding type is an enum.
It's pretty easy to write these lints, but I'm not sure if Rust is currently accepting more internal plugins or if this lint is something we really want, hence this issue first.
The text was updated successfully, but these errors were encountered:
At the moment, if an enum variant changes name, match arms containing it silently become wildcard matches. For example, the following:
will silently have the second arm becoming a wildcard arm if the original enum is changed (instead of a compile error which usually is how you can track down uses of a renamed identifier). In some cases we may get an "unreachable pattern" error, but not always.
I'm proposing we add a lint to warn against arms which are a single identifier bound to a variable instead of a variant. Instead, we suggest that
_ @ variable
arms are used.This doesn't handle patterns where enums are nested, i.e
Some(Bar)
whenBar
gets renamed. If we want to catch these too we might want to instead lint uppercasePatIdent
s anywhere in a match where the corresponding type is an enum.It's pretty easy to write these lints, but I'm not sure if Rust is currently accepting more internal plugins or if this lint is something we really want, hence this issue first.
The text was updated successfully, but these errors were encountered: