Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-dead
Record `LocalDefId` in HIR nodes instead of a side table This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR. This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed. This first part adds the information to HIR nodes themselves instead of a table. The second part is https://github.com/rust-lang/rust/pull/103902 The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter. The fourth part will be to completely remove the side table.
This commit is contained in:
commit
7c75fe4c85
63 changed files with 449 additions and 549 deletions
|
@ -220,19 +220,18 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
|
|||
|
||||
// Additionally, tuple struct/variant constructors have MIR, but
|
||||
// they don't have a BodyId, so we need to build them separately.
|
||||
struct GatherCtors<'a, 'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
struct GatherCtors<'a> {
|
||||
set: &'a mut FxIndexSet<LocalDefId>,
|
||||
}
|
||||
impl<'tcx> Visitor<'tcx> for GatherCtors<'_, 'tcx> {
|
||||
impl<'tcx> Visitor<'tcx> for GatherCtors<'_> {
|
||||
fn visit_variant_data(&mut self, v: &'tcx hir::VariantData<'tcx>) {
|
||||
if let hir::VariantData::Tuple(_, hir_id) = *v {
|
||||
self.set.insert(self.tcx.hir().local_def_id(hir_id));
|
||||
if let hir::VariantData::Tuple(_, _, def_id) = *v {
|
||||
self.set.insert(def_id);
|
||||
}
|
||||
intravisit::walk_struct_def(self, v)
|
||||
}
|
||||
}
|
||||
tcx.hir().visit_all_item_likes_in_crate(&mut GatherCtors { tcx, set: &mut set });
|
||||
tcx.hir().visit_all_item_likes_in_crate(&mut GatherCtors { set: &mut set });
|
||||
|
||||
set
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue