/// Compute all regions that are (currently) known to outlive free
/// regions. For these regions, we do not need to compute
/// liveness, since the outlives constraints will ensure that they
/// are live over the whole fn body anyhow.
Compute all regions that are (currently) known to outlive free
regions. For these regions, we do not need to compute
liveness, since the outlives constraints will ensure that they
are live over the whole fn body anyhow.
Compute all regions that are ( currently ) known to outlive free regions . For these regions we do not need to compute liveness since the outlives constraints will ensure that they are live over the whole fn body anyhow .
fn regions_that_outlive_free_regions(
    num_region_vars: usize,
    universal_regions: &UniversalRegions<'tcx>,
    constraint_set: &ConstraintSet,
) -> FxHashSet<RegionVid> {
    // Build a graph of the outlives constraints thus far. This is
    // a reverse graph, so for each constraint `R1: R2` we have an
    // edge `R2 -> R1`. Therefore, if we find all regions
    // reachable from each free region, we will have all the
    // regions that are forced to outlive some free region.
    let rev_constraint_graph = constraint_set.reverse_graph(num_region_vars);
    let rev_region_graph = rev_constraint_graph.region_graph(constraint_set);
    // Stack for the depth-first search. Start out with all the free regions.
    let mut stack: Vec<_> = universal_regions.universal_regions().collect();
    // Set of all free regions, plus anything that outlives them. Initially
    // just contains the free regions.
    let mut outlives_free_region: FxHashSet<_> = stack.iter().cloned().collect();
    // Do the DFS -- for each thing in the stack, find all things
    // that outlive it and add them to the set. If they are not,
    // push them onto the stack for later.
    while let Some(sub_region) = stack.pop() {
        stack.extend(
            rev_region_graph
                .outgoing_regions(sub_region)
                .filter(|&r| outlives_free_region.insert(r)),
        );
    }
    // Return the final set of things we visited.
    outlives_free_region
}
fn regions_that_outlive_free_regions ( num_region_vars : usize , universal_regions : & UniversalRegions < ' tcx > , constraint_set : & ConstraintSet , ) -> FxHashSet < RegionVid > { // Build a graph of the outlives constraints thus far. This is // a reverse graph, so for each constraint `R1: R2` we have an // edge `R2 -> R1`. Therefore, if we find all regions // reachable from each free region, we will have all the // regions that are forced to outlive some free region. let rev_constraint_graph = constraint_set . reverse_graph ( num_region_vars ) ; let rev_region_graph = rev_constraint_graph . region_graph ( constraint_set ) ; // Stack for the depth-first search. Start out with all the free regions. let mut stack : Vec < _ > = universal_regions . universal_regions ( ) . collect ( ) ; // Set of all free regions, plus anything that outlives them. Initially // just contains the free regions. let mut outlives_free_region : FxHashSet < _ > = stack . iter ( ) . cloned ( ) . collect ( ) ; // Do the DFS -- for each thing in the stack, find all things // that outlive it and add them to the set. If they are not, // push them onto the stack for later. while let Some ( sub_region ) = stack . pop ( ) { stack . extend ( rev_region_graph . outgoing_regions ( sub_region ) . filter ( | & r | outlives_free_region . insert ( r ) ) , ) ; } // Return the final set of things we visited. outlives_free_region }
Compute all regions that are (currently) known to outlive free
regions.
Compute all regions that are ( currently ) known to outlive free regions .
num_region_vars
usize
universal_regions
&UniversalRegions<'tcx>
constraint_set
&ConstraintSet