1
Fork 0

Always perform discr read for never pattern in EUV

This commit is contained in:
Michael Goulet 2025-02-11 20:57:02 +00:00
parent 8c61cd4df8
commit ffefb13443
2 changed files with 20 additions and 0 deletions

View file

@ -943,6 +943,10 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
let mutability = if mutable { hir::Mutability::Mut } else { hir::Mutability::Not };
let bk = ty::BorrowKind::from_mutbl(mutability);
self.delegate.borrow_mut().borrow(place, discr_place.hir_id, bk);
} else if let PatKind::Never = pat.kind {
// A `!` pattern always counts as an immutable read of the discriminant,
// even in an irrefutable pattern.
self.delegate.borrow_mut().borrow(place, discr_place.hir_id, BorrowKind::Immutable);
}
Ok(())