Fail gracefully if mutating on a use closure and the closure it not declared mut
This commit is contained in:
parent
6eb6ff62f7
commit
aa58439f87
3 changed files with 28 additions and 1 deletions
|
@ -823,7 +823,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
|
|||
) => {
|
||||
capture_reason = format!("mutable borrow of `{upvar}`");
|
||||
}
|
||||
ty::UpvarCapture::ByValue => {
|
||||
ty::UpvarCapture::ByValue | ty::UpvarCapture::ByUse => {
|
||||
capture_reason = format!("possible mutation of `{upvar}`");
|
||||
}
|
||||
_ => bug!("upvar `{upvar}` borrowed, but not mutably"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue