Skip to content

Commit 9faee0a

Browse files
Rollup merge of #154938 - jakubadamw:issue-104653, r=Nadrieril
match exhaustiveness: Show the guard exhaustivity note only when it's the guards alone that cause non-exhaustiveness Only show the "match arms with guards don't count towards exhaustivity" note when removing all guards would make the match exhaustive, but also in the cases when the match contains arms without guards. Previously, this note was shown only if all arms had guards, but even if the patterns themselves were insufficient to cover all valid values of a type. Do this by rerunning the exhaustiveness analysis with guards stripped to determine whether the guards are actually the cause of non-exhaustiveness. This only happens on an actual exhaustiveness error, so should not be a performance concern. This will make a program like: ```rust fn main() { let some_condition = true; let some_option: Option<u8> = None; let _res = match some_option { Some(val) if some_condition => val, None => 0, }; } ``` produce the note ”match arms with guards don't count towards exhaustivity” that previously would not have been appearing. Closes rust-lang/rust#104653 as I think this addresses the spirit of that issue. I don’t believe it’s necessary to be any more elaborate in the diagnostics here?
2 parents 36986f6 + a51f720 commit 9faee0a

0 file changed

File tree

    0 commit comments

    Comments
     (0)