Deduplicate Spans in Uninitialized Check

Prevents reporting labels or diagnostics on spans that are produced
multiple times.
This commit is contained in:
Stephen Lazaro
2024-08-20 17:53:30 -07:00
parent 4d5b3b1962
commit e91f32829c
3 changed files with 31 additions and 2 deletions

View File

@@ -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.push(span);
spans_set.insert(span);
}
}
let spans: Vec<_> = spans_set.into_iter().collect();
let (name, desc) = match self.describe_place_with_options(
moved_place,