Store a LocalDefId in hir::Variant & hir::Field.

This commit is contained in:
Camille GILLOT 2022-11-06 19:46:55 +00:00
parent 607d0c2a14
commit 9d20aca983
25 changed files with 122 additions and 149 deletions

View file

@ -217,19 +217,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
}