about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-01-13 18:51:07 +0000
committerbors <bors@rust-lang.org>2022-01-13 18:51:07 +0000
commit2e3b64deef7f70ff95b7ecb8270297fe04876ddd (patch)
tree1008027a4accff3382039a44c3f7e563683f7bbc
parentdda2aef64fb5b4903a28e5d4fb8d63483642cc6f (diff)
parent7e2ccb015445cc4faf291b1375e34c1c4d67339d (diff)
downloadrust-2e3b64deef7f70ff95b7ecb8270297fe04876ddd.tar.gz
rust-2e3b64deef7f70ff95b7ecb8270297fe04876ddd.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`
-rw-r--r--clippy_utils/src/lib.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs
index 91ebc7ea89c..90f5baffd22 100644
--- a/clippy_utils/src/lib.rs
+++ b/clippy_utils/src/lib.rs
@@ -976,8 +976,8 @@ pub fn can_move_expr_to_closure(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) ->
                         };
                         if !self.locals.contains(&local_id) {
                             let capture = match capture.info.capture_kind {
-                                UpvarCapture::ByValue(_) => CaptureKind::Value,
-                                UpvarCapture::ByRef(borrow) => match borrow.kind {
+                                UpvarCapture::ByValue => CaptureKind::Value,
+                                UpvarCapture::ByRef(kind) => match kind {
                                     BorrowKind::ImmBorrow => CaptureKind::Ref(Mutability::Not),
                                     BorrowKind::UniqueImmBorrow | BorrowKind::MutBorrow => {
                                         CaptureKind::Ref(Mutability::Mut)