Subpar diagnostics: unreachable_code lint fires before match arm coverage check #46426
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
When you do
#![deny(unreachable_code)]
(which is implied by#![deny(warnings)]
), the corresponding lint runs and aborts compilation before the match arm coverage check gets a chance to report.This leads to somewhat confusing messages.
match
expressions should hypothetically behave if they were not forced to cover the domain of the input expression completelyExample:
yields the error message (playpen)
which, when I first look at the code, I think "that
println!
is clearly reachable", because in my head, execution is going to continue past the match expression after that first arm is not matched.If I change the
deny
towarn
, I get both the warning as above as well as an error about the non-exhaustive patterns in the match expression, saying that&_
is not covered.The text was updated successfully, but these errors were encountered: