diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 743f4d9ca2a..60f090578f5 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -899,8 +899,8 @@ /// The second return value maps from ADTs to ignored derived traits (e.g. Debug and Clone) and /// their respective impl (i.e., part of the derive macro) query live_symbols_and_ignored_derived_traits(_: ()) -> &'tcx ( - FxHashSet, - FxHashMap> + LocalDefIdSet, + LocalDefIdMap> ) { arena_cache desc { "finding live symbols in crate" } diff --git a/compiler/rustc_middle/src/ty/query.rs b/compiler/rustc_middle/src/ty/query.rs index 4beb99e8add..10c37b74483 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -50,7 +50,9 @@ use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; use rustc_hir::def::{DefKind, DocLinkResMap}; -use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LocalDefIdSet}; +use rustc_hir::def_id::{ + CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LocalDefIdMap, LocalDefIdSet, +}; use rustc_hir::hir_id::OwnerId; use rustc_hir::lang_items::{LangItem, LanguageItems}; use rustc_hir::{Crate, ItemLocalId, TraitCandidate}; diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index e2f858a34b6..8a9c4cc8f7f 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -2,8 +2,8 @@ // closely. The idea is that all reachable symbols are live, codes called // from live codes are live, and everything else is dead. +use hir::def_id::{LocalDefIdMap, LocalDefIdSet}; use itertools::Itertools; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::MultiSpan; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; @@ -45,17 +45,17 @@ struct MarkSymbolVisitor<'tcx> { worklist: Vec, tcx: TyCtxt<'tcx>, maybe_typeck_results: Option<&'tcx ty::TypeckResults<'tcx>>, - live_symbols: FxHashSet, + live_symbols: LocalDefIdSet, repr_has_repr_c: bool, repr_has_repr_simd: bool, in_pat: bool, ignore_variant_stack: Vec, // maps from tuple struct constructors to tuple struct items - struct_constructors: FxHashMap, + struct_constructors: LocalDefIdMap, // maps from ADTs to ignored derived traits (e.g. Debug and Clone) // and the span of their respective impl (i.e., part of the derive // macro) - ignored_derived_traits: FxHashMap>, + ignored_derived_traits: LocalDefIdMap>, } impl<'tcx> MarkSymbolVisitor<'tcx> { @@ -237,7 +237,7 @@ fn handle_tuple_field_pattern_match( } fn mark_live_symbols(&mut self) { - let mut scanned = FxHashSet::default(); + let mut scanned = LocalDefIdSet::default(); while let Some(id) = self.worklist.pop() { if !scanned.insert(id) { continue; @@ -371,7 +371,7 @@ fn visit_variant_data(&mut self, def: &'tcx hir::VariantData<'tcx>) { } if tcx.visibility(def_id).is_public() { Some(def_id) } else { None } }); - self.live_symbols.extend(live_fields); + Extend::extend(&mut self.live_symbols, live_fields); intravisit::walk_struct_def(self, def); } @@ -506,7 +506,7 @@ fn has_used_like_attr(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { fn check_item<'tcx>( tcx: TyCtxt<'tcx>, worklist: &mut Vec, - struct_constructors: &mut FxHashMap, + struct_constructors: &mut LocalDefIdMap, id: hir::ItemId, ) { let allow_dead_code = has_allow_dead_code_or_lang_attr(tcx, id.owner_id.def_id); @@ -583,9 +583,7 @@ fn check_foreign_item(tcx: TyCtxt<'_>, worklist: &mut Vec, id: hir:: } } -fn create_and_seed_worklist( - tcx: TyCtxt<'_>, -) -> (Vec, FxHashMap) { +fn create_and_seed_worklist(tcx: TyCtxt<'_>) -> (Vec, LocalDefIdMap) { let effective_visibilities = &tcx.effective_visibilities(()); // see `MarkSymbolVisitor::struct_constructors` let mut struct_constructors = Default::default(); @@ -617,7 +615,7 @@ fn create_and_seed_worklist( fn live_symbols_and_ignored_derived_traits( tcx: TyCtxt<'_>, (): (), -) -> (FxHashSet, FxHashMap>) { +) -> (LocalDefIdSet, LocalDefIdMap>) { let (worklist, struct_constructors) = create_and_seed_worklist(tcx); let mut symbol_visitor = MarkSymbolVisitor { worklist, @@ -629,7 +627,7 @@ fn live_symbols_and_ignored_derived_traits( in_pat: false, ignore_variant_stack: vec![], struct_constructors, - ignored_derived_traits: FxHashMap::default(), + ignored_derived_traits: Default::default(), }; symbol_visitor.mark_live_symbols(); (symbol_visitor.live_symbols, symbol_visitor.ignored_derived_traits) @@ -643,8 +641,8 @@ struct DeadVariant { struct DeadVisitor<'tcx> { tcx: TyCtxt<'tcx>, - live_symbols: &'tcx FxHashSet, - ignored_derived_traits: &'tcx FxHashMap>, + live_symbols: &'tcx LocalDefIdSet, + ignored_derived_traits: &'tcx LocalDefIdMap>, } enum ShouldWarnAboutField {