Skip to main content

is_opsem_inhabited_recursor

Function is_opsem_inhabited_recursor 

Source
fn is_opsem_inhabited_recursor<'tcx, SEEN>(
    ty: Ty<'tcx>,
    tcx: TyCtxt<'tcx>,
    seen: &mut SEEN,
    stop_at_ref: bool,
    adt_handler: &impl Fn(Ty<'tcx>, &mut SEEN, &dyn Fn(Ty<'tcx>, &mut SEEN, bool) -> bool) -> bool,
) -> bool
Expand description

Recurse over a type to determine whether it is inhabited on the opsem level. See is_opsem_inhabited above for the spec of what we compute.

When we encounter an ADT, we call adt_handler, giving it as its last argument a closure that it can invoke to continue the recursion. This lets us share the logic for “simple” cases (i.e., everything except for ADTs) between Ty::is_opsem_inhabited and the query.

seen is used to detect infinite recursion: the set contains all ADTs that we encountered on our path to the current type. If stop_at_ref is true, we stop recursing at the next reference we encounter.