about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2023-04-19 18:12:39 +0000
committerMaybe Waffle <waffle.lapkin@gmail.com>2023-04-19 19:10:25 +0000
commitceabcd83e66144a26dcb90665a03c74c62593ff8 (patch)
tree9d2fc7abdd1a10452c4b45e8e36ab821d3a935a6
parent4eac6fe21e1f82b1cc3c528b6a4b241fe5509b40 (diff)
downloadrust-ceabcd83e66144a26dcb90665a03c74c62593ff8.tar.gz
rust-ceabcd83e66144a26dcb90665a03c74c62593ff8.zip
Remove useless check (drive-by cleanup)
While it might *seem* that this does something, it actually doesn't.
`mut_borrow_of_mutable_ref` returns a `bool` that is ignored by the
let-else. This was basically
```rust
if !self.body.local_decls.get(local).is_some() {
    return
}
```
Which is pretty useless
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs16
1 files changed, 1 insertions, 15 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index a4a3c738f47..9823657c038 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -30,7 +30,6 @@ use crate::borrow_set::TwoPhaseActivation;
 use crate::borrowck_errors;
 
 use crate::diagnostics::conflict_errors::StorageDeadOrDrop::LocalStorageDead;
-use crate::diagnostics::mutability_errors::mut_borrow_of_mutable_ref;
 use crate::diagnostics::{find_all_local_uses, CapturedMessageOpt};
 use crate::{
     borrow_set::BorrowData, diagnostics::Instance, prefixes::IsPrefixOf,
@@ -959,11 +958,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
                     &msg_borrow,
                     None,
                 );
-                self.suggest_binding_for_closure_capture_self(
-                    &mut err,
-                    issued_borrow.borrowed_place,
-                    &issued_spans,
-                );
+                self.suggest_binding_for_closure_capture_self(&mut err, &issued_spans);
                 err
             }
 
@@ -1271,20 +1266,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
     fn suggest_binding_for_closure_capture_self(
         &self,
         err: &mut Diagnostic,
-        borrowed_place: Place<'tcx>,
         issued_spans: &UseSpans<'tcx>,
     ) {
         let UseSpans::ClosureUse { capture_kind_span, .. } = issued_spans else { return };
         let hir = self.infcx.tcx.hir();
 
-        // check whether the borrowed place is capturing `self` by mut reference
-        let local = borrowed_place.local;
-        let Some(_) = self
-            .body
-            .local_decls
-            .get(local)
-            .map(|l| mut_borrow_of_mutable_ref(l, self.local_names[local])) else { return };
-
         struct ExpressionFinder<'hir> {
             capture_span: Span,
             closure_change_spans: Vec<Span>,