fn find_constraint_paths_between_regions(
        &self,
        from_region: RegionVid,
        target_test: impl Fn(RegionVid) -> bool,
    ) -> Option<(Vec<OutlivesConstraint>, RegionVid)> {
        let mut context = IndexVec::from_elem(Trace::NotVisited, &self.definitions);
        context[from_region] = Trace::StartRegion;

        // Use a deque so that we do a breadth-first search. We will
        // stop at the first match, which ought to be the shortest
        // path (fewest constraints).
        let mut deque = VecDeque::new();
        deque.push_back(from_region);

        while let Some(r) = deque.pop_front() {
            // Check if we reached the region we were looking for. If so,
            // we can reconstruct the path that led to it and return it.
            if target_test(r) {
                let mut result = vec![];
                let mut p = r;
                loop {
                    match context[p] {
                        Trace::NotVisited => {
                            bug!("found unvisited region {:?} on path to {:?}", p, r)
                        }
                        Trace::FromOutlivesConstraint(c) => {
                            result.push(c);
                            p = c.sup;
                        }

                        Trace::StartRegion => {
                            result.reverse();
                            return Some((result, r));
                        }
                    }
                }
            }

            // Otherwise, walk over the outgoing constraints and
            // enqueue any regions we find, keeping track of how we
            // reached them.
            let fr_static = self.universal_regions.fr_static;
            for constraint in self.constraint_graph.outgoing_edges(r,
                                                                   &self.constraints,
                                                                   fr_static) {
                assert_eq!(constraint.sup, r);
                let sub_region = constraint.sub;
                if let Trace::NotVisited = context[sub_region] {
                    context[sub_region] = Trace::FromOutlivesConstraint(constraint);
                    deque.push_back(sub_region);
                }
            }
        }

        None
    }
/// Walks the graph of constraints (where `'a: 'b` is considered
/// an edge `'a -> 'b`) to find all paths from `from_region` to
/// `to_region`. The paths are accumulated into the vector
/// `results`. The paths are stored as a series of
/// `ConstraintIndex` values -- in other words, a list of *edges*.
///
/// Returns: a series of constraints as well as the region `R`
/// that passed the target test.


a series of constraints as well as the region `R`
that passed the target test.
a series of constraints as well as the region ` R ` that passed the target test .
fn find_constraint_paths_between_regions(
        &self,
        from_region: RegionVid,
        target_test: impl Fn(RegionVid) -> bool,
    ) -> Option<(Vec<OutlivesConstraint>, RegionVid)> {
        let mut context = IndexVec::from_elem(Trace::NotVisited, &self.definitions);
        context[from_region] = Trace::StartRegion;
        // Use a deque so that we do a breadth-first search. We will
        // stop at the first match, which ought to be the shortest
        // path (fewest constraints).
        let mut deque = VecDeque::new();
        deque.push_back(from_region);
        while let Some(r) = deque.pop_front() {
            // Check if we reached the region we were looking for. If so,
            // we can reconstruct the path that led to it and return it.
            if target_test(r) {
                let mut result = vec![];
                let mut p = r;
                loop {
                    match context[p] {
                        Trace::NotVisited => {
                            bug!("found unvisited region {:?} on path to {:?}", p, r)
                        }
                        Trace::FromOutlivesConstraint(c) => {
                            result.push(c);
                            p = c.sup;
                        }
                        Trace::StartRegion => {
                            result.reverse();
                            return Some((result, r));
                        }
                    }
                }
            }
            // Otherwise, walk over the outgoing constraints and
            // enqueue any regions we find, keeping track of how we
            // reached them.
            let fr_static = self.universal_regions.fr_static;
            for constraint in self.constraint_graph.outgoing_edges(r,
                                                                   &self.constraints,
                                                                   fr_static) {
                assert_eq!(constraint.sup, r);
                let sub_region = constraint.sub;
                if let Trace::NotVisited = context[sub_region] {
                    context[sub_region] = Trace::FromOutlivesConstraint(constraint);
                    deque.push_back(sub_region);
                }
            }
        }
        None
    }
fn find_constraint_paths_between_regions ( & self , from_region : RegionVid , target_test : impl Fn ( RegionVid ) -> bool , ) -> Option < ( Vec < OutlivesConstraint > , RegionVid ) > { let mut context = IndexVec :: from_elem ( Trace :: NotVisited , & self . definitions ) ; context [ from_region ] = Trace :: StartRegion ; // Use a deque so that we do a breadth-first search. We will // stop at the first match, which ought to be the shortest // path (fewest constraints). let mut deque = VecDeque :: new ( ) ; deque . push_back ( from_region ) ; while let Some ( r ) = deque . pop_front ( ) { // Check if we reached the region we were looking for. If so, // we can reconstruct the path that led to it and return it. if target_test ( r ) { let mut result = vec ! [ ] ; let mut p = r ; loop { match context [ p ] { Trace :: NotVisited => { bug ! ( " " p r ) } Trace :: FromOutlivesConstraint ( c ) => { result . push ( c ) ; p = c . sup ; } Trace :: StartRegion => { result . reverse ( ) ; return Some ( ( result , r ) ) ; } } } } // Otherwise, walk over the outgoing constraints and // enqueue any regions we find, keeping track of how we // reached them. let fr_static = self . universal_regions . fr_static ; for constraint in self . constraint_graph . outgoing_edges ( r , & self . constraints , fr_static ) { assert_eq ! ( constraint sup r ) ; let sub_region = constraint . sub ; if let Trace :: NotVisited = context [ sub_region ] { context [ sub_region ] = Trace :: FromOutlivesConstraint ( constraint ) ; deque . push_back ( sub_region ) ; } } } None }
Walks the graph of constraints (where `'a: 'b` is considered
an edge `'a -> 'b`) to find all paths from `from_region` to
`to_region`.
Walks the graph of constraints ( where ` ' a : ' b ` is considered an edge ` ' a - > ' b ` ) to find all paths from ` from_region ` to ` to_region ` .
&self
from_region
RegionVid
target_test
impl Fn(RegionVid) -> bool
&self
from_region
RegionVid
target_test
impl Fn(RegionVid) -> bool