E4226#
Compiler diagnostic name: constr_any_pattern_scrutinee_not_error.
The wildcard constructor pattern Type::_ is being matched against a value
whose type is not Error.
Type::_ selects every constructor belonging to one suberror type while
matching the open Error type. It is not an alternative spelling for an
ordinary exhaustive match on a value already typed as that suberror.
Erroneous example#
///|
priv suberror ParseError {
InvalidSyntax
}
///|
pub fn is_parse_error(error : ParseError) -> Bool {
match error {
ParseError::_ => true
}
}
Suggestion#
Use Type::_ when matching an Error, and retain a final _ branch for other
suberror types. When the matched value already has the concrete suberror type,
list its constructors normally.
///|
priv suberror ParseError {
InvalidSyntax
}
///|
pub fn is_parse_error(error : Error) -> Bool {
match error {
ParseError::_ => true
_ => false
}
}