E0093#
Warning name: unknown_constr_pat_on_exhaustive_type
A Type::.. pattern is used with an enum that is not marked
#non_exhaustive. Closed enums have no unknown future constructor for this
pattern to match, so the pattern is meaningless.
Erroneous example#
///|
pub(all) enum Status {
Ready
Busy
}
///|
pub fn describe(status : Status) -> String {
match status {
Ready => "ready"
Busy => "busy"
Status::.. => "unknown"
}
}
Suggestion#
Remove the Type::.. case from a closed enum match. If the enum is a public
extension point whose defining package may add constructors in future releases,
mark its declaration with #non_exhaustive, match every currently known
constructor explicitly, and keep Type::.. as the final compatibility case.
///|
#non_exhaustive
pub(all) enum Status {
Ready
Busy
}
///|
pub fn describe(status : Status) -> String {
match status {
Ready => "ready"
Busy => "busy"
Status::.. => "unknown"
}
}