Skip to content

Commit fdb0651

Browse files
committed
Only scan each definition once.
1 parent effc509 commit fdb0651

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

compiler/rustc_passes/src/dead.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::mem;
88
use hir::def_id::{LocalDefIdMap, LocalDefIdSet};
99
use rustc_abi::FieldIdx;
1010
use rustc_data_structures::fx::FxIndexSet;
11-
use rustc_data_structures::unord::UnordSet;
1211
use rustc_errors::MultiSpan;
1312
use rustc_hir::def::{CtorOf, DefKind, Res};
1413
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
@@ -80,7 +79,7 @@ struct MarkSymbolVisitor<'tcx> {
8079
worklist: Vec<(LocalDefId, ComesFromAllowExpect)>,
8180
tcx: TyCtxt<'tcx>,
8281
maybe_typeck_results: Option<&'tcx ty::TypeckResults<'tcx>>,
83-
scanned: UnordSet<(LocalDefId, ComesFromAllowExpect)>,
82+
scanned: LocalDefIdSet,
8483
live_symbols: LocalDefIdSet,
8584
repr_unconditionally_treats_fields_as_live: bool,
8685
repr_has_repr_simd: bool,
@@ -324,10 +323,6 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
324323

325324
fn mark_live_symbols(&mut self) {
326325
while let Some(work) = self.worklist.pop() {
327-
if !self.scanned.insert(work) {
328-
continue;
329-
}
330-
331326
let (mut id, comes_from_allow_expect) = work;
332327

333328
// Avoid accessing the HIR for the synthesized associated type generated for RPITITs.
@@ -363,9 +358,17 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
363358
// this "duplication" is essential as otherwise a function with `#[expect]`
364359
// called from a `pub fn` may be falsely reported as not live, falsely
365360
// triggering the `unfulfilled_lint_expectations` lint.
366-
if comes_from_allow_expect != ComesFromAllowExpect::Yes {
367-
self.live_symbols.insert(id);
361+
match comes_from_allow_expect {
362+
ComesFromAllowExpect::Yes => {}
363+
ComesFromAllowExpect::No => {
364+
self.live_symbols.insert(id);
365+
}
368366
}
367+
368+
if !self.scanned.insert(id) {
369+
continue;
370+
}
371+
369372
self.visit_node(self.tcx.hir_node_by_def_id(id));
370373
}
371374
}

0 commit comments

Comments
 (0)