Skip to content

Commit 3c3a7ba

Browse files
committed
Allocate fewer Strings at a time
1 parent 81c27c6 commit 3c3a7ba

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/librustc_mir/borrow_check/move_errors.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
383383
err: &mut DiagnosticBuilder<'a>,
384384
binds_to: &[Local],
385385
) {
386-
let mut suggestions: Vec<(Span, String, String)> = Vec::new();
386+
let mut suggestions: Vec<(Span, &str, String)> = Vec::new();
387387
for local in binds_to {
388388
let bind_to = &self.mir.local_decls[*local];
389389
if let Some(
@@ -411,16 +411,20 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
411411
}
412412
suggestions.push((
413413
pat_span,
414-
format!("consider removing the `{}`", to_remove),
414+
to_remove,
415415
suggestion.to_owned(),
416416
));
417417
}
418418
}
419419
}
420420
suggestions.sort_unstable_by_key(|&(span, _, _)| span);
421421
suggestions.dedup_by_key(|&mut (span, _, _)| span);
422-
for (span, msg, suggestion) in suggestions {
423-
err.span_suggestion(span, &msg, suggestion);
422+
for (span, to_remove, suggestion) in suggestions {
423+
err.span_suggestion(
424+
span,
425+
&format!("consider removing the `{}`", to_remove),
426+
suggestion
427+
);
424428
}
425429
}
426430

0 commit comments

Comments
 (0)