1
Fork 0

Fix span for IndexMut method call on HashMap/BTreeMap

This commit is contained in:
Michael Goulet 2024-12-31 01:20:45 +00:00
parent 6a3474e653
commit f28e13b055
3 changed files with 10 additions and 4 deletions

View file

@ -624,7 +624,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
self.suggested = true;
} else if let hir::ExprKind::MethodCall(_path, receiver, _, sp) = expr.kind
&& let hir::ExprKind::Index(val, index, _) = receiver.kind
&& expr.span == self.assign_span
&& receiver.span == self.assign_span
{
// val[index].path(args..);
self.err.multipart_suggestion(
@ -639,7 +639,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
index.span.shrink_to_hi().with_hi(receiver.span.hi()),
") { val".to_string(),
),
(sp.shrink_to_hi(), "); }".to_string()),
(sp.shrink_to_hi(), "; }".to_string()),
],
Applicability::MachineApplicable,
);