1
Fork 0

Rollup merge of #119835 - Nadrieril:simplify-empty-logic, r=compiler-errors

Exhaustiveness: simplify empty pattern logic

The logic that handles empty patterns had gotten quite convoluted. This PR simplifies it a lot. I tried to make the logic as easy as possible to follow; this only does logically equivalent changes.

The first commit is a drive-by comment clarification that was requested after another PR a while back.

r? `@compiler-errors`
This commit is contained in:
Matthias Krüger 2024-01-19 19:27:00 +01:00 committed by GitHub
commit 2587100a9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 30 additions and 51 deletions

View file

@ -289,7 +289,8 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
fn is_known_valid_scrutinee(&self, scrutinee: &Expr<'tcx>) -> bool {
use ExprKind::*;
match &scrutinee.kind {
// Both pointers and references can validly point to a place with invalid data.
// Pointers can validly point to a place with invalid data. It is undecided whether
// references can too, so we conservatively assume they can.
Deref { .. } => false,
// Inherit validity of the parent place, unless the parent is an union.
Field { lhs, .. } => {