rustc_utils/mir/
adt_def.rs1use rustc_hir::def_id::DefId;
4use rustc_middle::ty::{AdtDef, FieldDef, TyCtxt};
5
6pub trait AdtDefExt<'tcx> {
8 fn all_visible_fields(
11 self,
12 module: DefId,
13 tcx: TyCtxt<'tcx>,
14 ) -> impl Iterator<Item = &'tcx FieldDef>;
15}
16
17impl<'tcx> AdtDefExt<'tcx> for AdtDef<'tcx> {
18 fn all_visible_fields(
19 self,
20 module: DefId,
21 tcx: TyCtxt<'tcx>,
22 ) -> impl Iterator<Item = &'tcx FieldDef> {
23 self
24 .all_fields()
25 .filter(move |field| field.vis.is_accessible_from(module, tcx))
26 }
27}