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(())
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
//@ check-pass
|
||||
|
||||
// Make sure that the closure captures `s` so it can perform a read of `s`.
|
||||
|
||||
#![feature(never_patterns)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
enum Void {}
|
||||
|
||||
fn by_value(s: Void) {
|
||||
move || {
|
||||
let ! = s;
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue