Skip to content

Commit dbef0ab

Browse files
Use a set for obvious performance and correctness reasons
1 parent 8014c84 commit dbef0ab

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -678,14 +678,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
678678
let inits = &self.move_data.init_path_map[mpi];
679679
let move_path = &self.move_data.move_paths[mpi];
680680
let decl_span = self.body.local_decls[move_path.place.local].source_info.span;
681-
let mut spans = vec![];
681+
let mut spans_set = FxIndexSet::default();
682682
for init_idx in inits {
683683
let init = &self.move_data.inits[*init_idx];
684684
let span = init.span(self.body);
685-
if !span.is_dummy() && !spans.contains(&span) {
686-
spans.push(span);
685+
if !span.is_dummy() {
686+
spans_set.insert(span);
687687
}
688688
}
689+
let spans: Vec<_> = spans_set.into_iter().collect();
689690

690691
let (name, desc) = match self.describe_place_with_options(
691692
moved_place,

0 commit comments

Comments
 (0)