Skip to content

Commit

Permalink
Use a set for obvious performance and correctness reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-lazaro committed Aug 22, 2024
1 parent 8014c84 commit dbef0ab
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,14 +678,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
let inits = &self.move_data.init_path_map[mpi];
let move_path = &self.move_data.move_paths[mpi];
let decl_span = self.body.local_decls[move_path.place.local].source_info.span;
let mut spans = vec![];
let mut spans_set = FxIndexSet::default();
for init_idx in inits {
let init = &self.move_data.inits[*init_idx];
let span = init.span(self.body);
if !span.is_dummy() && !spans.contains(&span) {
spans.push(span);
if !span.is_dummy() {
spans_set.insert(span);
}
}
let spans: Vec<_> = spans_set.into_iter().collect();

let (name, desc) = match self.describe_place_with_options(
moved_place,
Expand Down

0 comments on commit dbef0ab

Please sign in to comment.