1
Fork 0

Do not suggest ref multiple times for the same binding

This commit is contained in:
Esteban Küber 2022-11-03 09:19:03 -07:00
parent 9e72e35ceb
commit 4a51f37bcb
2 changed files with 3 additions and 9 deletions

View file

@ -171,6 +171,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let mut is_loop_move = false;
let mut in_pattern = false;
let mut seen_spans = FxHashSet::default();
for move_site in &move_site_vec {
let move_out = self.move_data.moves[(*move_site).moi];
@ -320,7 +321,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
self.suggest_cloning(&mut err, ty, move_span);
}
}
if let Some(pat) = finder.pat {
if let Some(pat) = finder.pat && !seen_spans.contains(&pat.span) {
in_pattern = true;
err.span_suggestion_verbose(
pat.span.shrink_to_lo(),
@ -328,6 +329,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
"ref ".to_string(),
Applicability::MachineApplicable,
);
seen_spans.insert(pat.span);
}
}