warning unreachable-arm
Ветка match недостижима.
What it means#
An arm is unreachable if the earlier arms already cover every value it could match, for example an arm after _ or a repeated pattern (§5.5). This is a warning by default, configurable in [lint].
Example#
enum Role { User, Admin }
fn label(r: Role) -> str {
match r {
_ => "other"
Role.Admin => "admin" // <- unreachable-arm
}
}error
unreachable-arm
How to fix#
enum Role { User, Admin }
fn label(r: Role) -> str {
match r {
Role.Admin => "admin"
_ => "other"
}
}Move the specific arm before the general one, or delete the dead arm.