Skip to content

Commit ceabcd8

Browse files
committed
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
1 parent 4eac6fe commit ceabcd8

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use crate::borrow_set::TwoPhaseActivation;
3030
use crate::borrowck_errors;
3131

3232
use crate::diagnostics::conflict_errors::StorageDeadOrDrop::LocalStorageDead;
33-
use crate::diagnostics::mutability_errors::mut_borrow_of_mutable_ref;
3433
use crate::diagnostics::{find_all_local_uses, CapturedMessageOpt};
3534
use crate::{
3635
borrow_set::BorrowData, diagnostics::Instance, prefixes::IsPrefixOf,
@@ -959,11 +958,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
959958
&msg_borrow,
960959
None,
961960
);
962-
self.suggest_binding_for_closure_capture_self(
963-
&mut err,
964-
issued_borrow.borrowed_place,
965-
&issued_spans,
966-
);
961+
self.suggest_binding_for_closure_capture_self(&mut err, &issued_spans);
967962
err
968963
}
969964

@@ -1271,20 +1266,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12711266
fn suggest_binding_for_closure_capture_self(
12721267
&self,
12731268
err: &mut Diagnostic,
1274-
borrowed_place: Place<'tcx>,
12751269
issued_spans: &UseSpans<'tcx>,
12761270
) {
12771271
let UseSpans::ClosureUse { capture_kind_span, .. } = issued_spans else { return };
12781272
let hir = self.infcx.tcx.hir();
12791273

1280-
// check whether the borrowed place is capturing `self` by mut reference
1281-
let local = borrowed_place.local;
1282-
let Some(_) = self
1283-
.body
1284-
.local_decls
1285-
.get(local)
1286-
.map(|l| mut_borrow_of_mutable_ref(l, self.local_names[local])) else { return };
1287-
12881274
struct ExpressionFinder<'hir> {
12891275
capture_span: Span,
12901276
closure_change_spans: Vec<Span>,

0 commit comments

Comments
 (0)