Trait rustc_privacy::DefIdVisitor
source · pub(crate) trait DefIdVisitor<'tcx> {
type BreakTy = ();
const SHALLOW: bool = false;
const SKIP_ASSOC_TYS: bool = false;
// Required methods
fn tcx(&self) -> TyCtxt<'tcx>;
fn visit_def_id(
&mut self,
def_id: DefId,
kind: &str,
descr: &dyn Display
) -> ControlFlow<Self::BreakTy>;
// Provided methods
fn skeleton(&mut self) -> DefIdVisitorSkeleton<'_, 'tcx, Self> { ... }
fn visit(
&mut self,
ty_fragment: impl TypeVisitable<TyCtxt<'tcx>>
) -> ControlFlow<Self::BreakTy> { ... }
fn visit_trait(
&mut self,
trait_ref: TraitRef<'tcx>
) -> ControlFlow<Self::BreakTy> { ... }
fn visit_projection_ty(
&mut self,
projection: AliasTy<'tcx>
) -> ControlFlow<Self::BreakTy> { ... }
fn visit_predicates(
&mut self,
predicates: GenericPredicates<'tcx>
) -> ControlFlow<Self::BreakTy> { ... }
fn visit_clauses(
&mut self,
clauses: &[(Clause<'tcx>, Span)]
) -> ControlFlow<Self::BreakTy> { ... }
}
Expand description
Implemented to visit all DefId
s in a type.
Visiting DefId
s is useful because visibilities and reachabilities are attached to them.
The idea is to visit “all components of a type”, as documented in
https://github.com/rust-lang/rfcs/blob/master/text/2145-type-privacy.md#how-to-determine-visibility-of-a-type.
The default type visitor (TypeVisitor
) does most of the job, but it has some shortcomings.
First, it doesn’t have overridable fn visit_trait_ref
, so we have to catch trait DefId
s
manually. Second, it doesn’t visit some type components like signatures of fn types, or traits
in impl Trait
, see individual comments in DefIdVisitorSkeleton::visit_ty
.
Provided Associated Types§
Provided Associated Constants§
Required Methods§
fn tcx(&self) -> TyCtxt<'tcx>
fn visit_def_id( &mut self, def_id: DefId, kind: &str, descr: &dyn Display ) -> ControlFlow<Self::BreakTy>
Provided Methods§
sourcefn skeleton(&mut self) -> DefIdVisitorSkeleton<'_, 'tcx, Self>
fn skeleton(&mut self) -> DefIdVisitorSkeleton<'_, 'tcx, Self>
Not overridden, but used to actually visit types and traits.