Always perform discr read for never pattern in EUV
This commit is contained in:
parent
8c61cd4df8
commit
ffefb13443
2 changed files with 20 additions and 0 deletions
|
@ -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(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue