diff options
| author | bors <bors@rust-lang.org> | 2022-01-13 18:51:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-01-13 18:51:07 +0000 |
| commit | 22e491ac7ed454d34669151a8b6464cb643c9b41 (patch) | |
| tree | 8e30fdbc16b29cd272052aad7f885453ff789841 /compiler/rustc_borrowck/src | |
| parent | 256721ee519f6ff15dc5c1cfaf3ebf9af75efa4a (diff) | |
| parent | c84cea9c25e8db73b1b580ab9c7f72985a05da4d (diff) | |
| download | rust-22e491ac7ed454d34669151a8b6464cb643c9b41.tar.gz rust-22e491ac7ed454d34669151a8b6464cb643c9b41.zip | |
Auto merge of #89861 - nbdd0121:closure, r=wesleywiser
Closure capture cleanup & refactor Follow up of #89648 Each commit is self-contained and the rationale/changes are documented in the commit message, so it's advisable to review commit by commit. The code is significantly cleaner (at least IMO), but that could have some perf implication, so I'd suggest a perf run. r? `@wesleywiser` cc `@arora-aman`
Diffstat (limited to 'compiler/rustc_borrowck/src')
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_borrowck/src/lib.rs | 2 |
2 files changed, 5 insertions, 6 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index b5dad5ccdea..02935af8314 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -706,13 +706,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { &origin_projection, ) { match captured_place.info.capture_kind { - ty::UpvarCapture::ByRef(ty::UpvarBorrow { - kind: ty::BorrowKind::MutBorrow | ty::BorrowKind::UniqueImmBorrow, - .. - }) => { + ty::UpvarCapture::ByRef( + ty::BorrowKind::MutBorrow | ty::BorrowKind::UniqueImmBorrow, + ) => { capture_reason = format!("mutable borrow of `{}`", upvar); } - ty::UpvarCapture::ByValue(_) => { + ty::UpvarCapture::ByValue => { capture_reason = format!("possible mutation of `{}`", upvar); } _ => bug!("upvar `{}` borrowed, but not mutably", upvar), diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index fe34d6e7ca9..7e961e1e750 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -186,7 +186,7 @@ fn do_mir_borrowck<'a, 'tcx>( .map(|captured_place| { let capture = captured_place.info.capture_kind; let by_ref = match capture { - ty::UpvarCapture::ByValue(_) => false, + ty::UpvarCapture::ByValue => false, ty::UpvarCapture::ByRef(..) => true, }; Upvar { place: captured_place.clone(), by_ref } |
