Skip to content

Commit 718a3b1

Browse files
Fix issue 91206
1 parent 862962b commit 718a3b1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -447,16 +447,20 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
447447
// check if the RHS is from desugaring
448448
let opt_assignment_rhs_span =
449449
self.body.find_assignments(local).first().map(|&location| {
450-
let stmt = &self.body[location.block].statements
451-
[location.statement_index];
452-
match stmt.kind {
453-
mir::StatementKind::Assign(box (
454-
_,
455-
mir::Rvalue::Use(mir::Operand::Copy(place)),
456-
)) => {
457-
self.body.local_decls[place.local].source_info.span
458-
}
459-
_ => self.body.source_info(location).span,
450+
if let Some(mir::Statement {
451+
source_info: _,
452+
kind:
453+
mir::StatementKind::Assign(box (
454+
_,
455+
mir::Rvalue::Use(mir::Operand::Copy(place)),
456+
)),
457+
}) = self.body[location.block]
458+
.statements
459+
.get(location.statement_index)
460+
{
461+
self.body.local_decls[place.local].source_info.span
462+
} else {
463+
self.body.source_info(location).span
460464
}
461465
});
462466
match opt_assignment_rhs_span.and_then(|s| s.desugaring_kind()) {

0 commit comments

Comments
 (0)