1
Fork 0

add note for non-exhaustive matches with guards

This commit is contained in:
Eric Mark Martin 2023-06-22 01:52:31 -04:00
parent 6b46c996e1
commit fbd1e0252f
8 changed files with 60 additions and 24 deletions

View file

@ -830,6 +830,11 @@ fn non_exhaustive_match<'p, 'tcx>(
_ => " or multiple match arms",
},
);
let all_arms_have_guards = arms.iter().all(|arm_id| thir[*arm_id].guard.is_some());
if !is_empty_match && all_arms_have_guards {
err.note("match arms with guards don't count towards exhaustivity");
}
if let Some((span, sugg)) = suggestion {
err.span_suggestion_verbose(span, msg, sugg, Applicability::HasPlaceholders);
} else {