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
This commit is contained in:
parent
4eac6fe21e
commit
ceabcd83e6
@ -30,7 +30,6 @@
|
||||
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 @@ pub(crate) fn report_conflicting_borrow(
|
||||
&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 @@ fn suggest_split_at_mut_if_applicable(
|
||||
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>,
|
||||
|
Loading…
Reference in New Issue
Block a user