fn activate_deps_loop(mut cx: Context,
                      registry: &mut Registry,
                      top: Rc<Summary>,
                      top_method: &Method) -> CargoResult<Resolve> {
    let mut backtrack_stack = Vec::new();
    let mut remaining_deps = Vec::new();
    remaining_deps.extend(try!(activate(&mut cx, registry, top, &top_method)));

    // Main resolution loop, this is the workhorse of the resolution algorithm.
    //
    // You'll note that a few stacks are maintained on the side, which might
    // seem odd when this algorithm looks like it could be implemented
    // recursively. While correct, this is implemented iteratively to avoid
    // blowing the stack (the recusion depth is proportional to the size of the
    // input).
    //
    // The general sketch of this loop is to run until there are no dependencies
    // left to activate, and for each dependency to attempt to activate all of
    // its own dependencies in turn. The `backtrack_stack` is a side table of
    // backtracking states where if we hit an error we can return to in order to
    // attempt to continue resolving.
    while let Some(mut deps_frame) = remaining_deps.pop() {
        let frame = match deps_frame.remaining_siblings.next() {
            Some(sibling) => {
                let parent = deps_frame.parent.clone();
                remaining_deps.push(deps_frame);
                (parent, sibling)
            }
            None => {
                cx.visited.remove(&deps_frame.id);
                continue
            }
        };
        let (mut parent, (mut cur, (mut dep, candidates, features))) = frame;
        assert!(!remaining_deps.is_empty());

        let method = Method::Required {
            dev_deps: false,
            features: &features,
            uses_default_features: dep.uses_default_features(),
        };

        let my_candidates = {
            let prev_active = cx.prev_active(&dep);
            trace!("{}[{}]>{} {} candidates", parent.name(), cur, dep.name(),
                   candidates.len());
            trace!("{}[{}]>{} {} prev activations", parent.name(), cur,
                   dep.name(), prev_active.len());

            // Filter the set of candidates based on the previously activated
            // versions for this dependency. We can actually use a version if it
            // precisely matches an activated version or if it is otherwise
            // incompatible with all other activated versions. Note that we
            // define "compatible" here in terms of the semver sense where if
            // the left-most nonzero digit is the same they're considered
            // compatible.
            candidates.iter().filter(|&b| {
                prev_active.iter().any(|a| a == b) ||
                    prev_active.iter().all(|a| {
                        !compatible(a.version(), b.version())
                    })
            }).cloned().collect()
        };

        // Alright, for each candidate that's gotten this far, it meets the
        // following requirements:
        //
        // 1. The version matches the dependency requirement listed for this
        //    package
        // 2. There are no activated versions for this package which are
        //    semver-compatible, or there's an activated version which is
        //    precisely equal to `candidate`.
        //
        // This means that we're going to attempt to activate each candidate in
        // turn. We could possibly fail to activate each candidate, so we try
        // each one in turn.
        let mut remaining_candidates = RcVecIter::new(my_candidates);
        let candidate = match remaining_candidates.next() {
            Some((_, candidate)) => {
                // We have a candidate. Add an entry to the `backtrack_stack` so
                // we can try the next one if this one fails.
                backtrack_stack.push(BacktrackFrame {
                    context_backup: cx.clone(),
                    deps_backup: remaining_deps.clone(),
                    remaining_candidates: remaining_candidates,
                    parent: parent.clone(),
                    dep: dep.clone(),
                });
                candidate
            }
            None => {
                // This dependency has no valid candidate. Backtrack until we
                // find a dependency that does have a candidate to try, and try
                // to activate that one.  This resets the `remaining_deps` to
                // their state at the found level of the `backtrack_stack`.
                trace!("{}[{}]>{} -- no candidates", parent.name(), cur,
                       dep.name());
                match find_candidate(&mut backtrack_stack, &mut cx,
                                     &mut remaining_deps, &mut parent, &mut cur,
                                     &mut dep) {
                    None => return Err(activation_error(&cx, registry, &parent,
                                                        &dep,
                                                        &cx.prev_active(&dep),
                                                        &candidates)),
                    Some(candidate) => candidate,
                }
            }
        };

        trace!("{}[{}]>{} trying {}", parent.name(), cur, dep.name(),
               candidate.version());
        cx.resolve.graph.link(parent.package_id().clone(),
                              candidate.package_id().clone());

        // If we hit an intransitive dependency then clear out the visitation
        // list as we can't induce a cycle through transitive dependencies.
        if !dep.is_transitive() {
            cx.visited.clear();
        }
        remaining_deps.extend(try!(activate(&mut cx, registry,
                                            candidate, &method)));
    }
    trace!("resolved: {:?}", cx.resolve);
    Ok(cx.resolve)
}
/// Recursively activates the dependencies for `top`, in depth-first order,
/// backtracking across possible candidates for each dependency as necessary.
///
/// If all dependencies can be activated and resolved to a version in the
/// dependency graph, cx.resolve is returned.
Recursively activates the dependencies for `top`, in depth-first order,
backtracking across possible candidates for each dependency as necessary.

If all dependencies can be activated and resolved to a version in the
dependency graph, cx.resolve is returned.
Recursively activates the dependencies for ` top ` in depth - first order backtracking across possible candidates for each dependency as necessary . If all dependencies can be activated and resolved to a version in the dependency graph cx . resolve is returned .
fn activate_deps_loop(mut cx: Context,
                      registry: &mut Registry,
                      top: Rc<Summary>,
                      top_method: &Method) -> CargoResult<Resolve> {
    let mut backtrack_stack = Vec::new();
    let mut remaining_deps = Vec::new();
    remaining_deps.extend(try!(activate(&mut cx, registry, top, &top_method)));
    // Main resolution loop, this is the workhorse of the resolution algorithm.
    //
    // You'll note that a few stacks are maintained on the side, which might
    // seem odd when this algorithm looks like it could be implemented
    // recursively. While correct, this is implemented iteratively to avoid
    // blowing the stack (the recusion depth is proportional to the size of the
    // input).
    //
    // The general sketch of this loop is to run until there are no dependencies
    // left to activate, and for each dependency to attempt to activate all of
    // its own dependencies in turn. The `backtrack_stack` is a side table of
    // backtracking states where if we hit an error we can return to in order to
    // attempt to continue resolving.
    while let Some(mut deps_frame) = remaining_deps.pop() {
        let frame = match deps_frame.remaining_siblings.next() {
            Some(sibling) => {
                let parent = deps_frame.parent.clone();
                remaining_deps.push(deps_frame);
                (parent, sibling)
            }
            None => {
                cx.visited.remove(&deps_frame.id);
                continue
            }
        };
        let (mut parent, (mut cur, (mut dep, candidates, features))) = frame;
        assert!(!remaining_deps.is_empty());
        let method = Method::Required {
            dev_deps: false,
            features: &features,
            uses_default_features: dep.uses_default_features(),
        };
        let my_candidates = {
            let prev_active = cx.prev_active(&dep);
            trace!("{}[{}]>{} {} candidates", parent.name(), cur, dep.name(),
                   candidates.len());
            trace!("{}[{}]>{} {} prev activations", parent.name(), cur,
                   dep.name(), prev_active.len());
            // Filter the set of candidates based on the previously activated
            // versions for this dependency. We can actually use a version if it
            // precisely matches an activated version or if it is otherwise
            // incompatible with all other activated versions. Note that we
            // define "compatible" here in terms of the semver sense where if
            // the left-most nonzero digit is the same they're considered
            // compatible.
            candidates.iter().filter(|&b| {
                prev_active.iter().any(|a| a == b) ||
                    prev_active.iter().all(|a| {
                        !compatible(a.version(), b.version())
                    })
            }).cloned().collect()
        };
        // Alright, for each candidate that's gotten this far, it meets the
        // following requirements:
        //
        // 1. The version matches the dependency requirement listed for this
        //    package
        // 2. There are no activated versions for this package which are
        //    semver-compatible, or there's an activated version which is
        //    precisely equal to `candidate`.
        //
        // This means that we're going to attempt to activate each candidate in
        // turn. We could possibly fail to activate each candidate, so we try
        // each one in turn.
        let mut remaining_candidates = RcVecIter::new(my_candidates);
        let candidate = match remaining_candidates.next() {
            Some((_, candidate)) => {
                // We have a candidate. Add an entry to the `backtrack_stack` so
                // we can try the next one if this one fails.
                backtrack_stack.push(BacktrackFrame {
                    context_backup: cx.clone(),
                    deps_backup: remaining_deps.clone(),
                    remaining_candidates: remaining_candidates,
                    parent: parent.clone(),
                    dep: dep.clone(),
                });
                candidate
            }
            None => {
                // This dependency has no valid candidate. Backtrack until we
                // find a dependency that does have a candidate to try, and try
                // to activate that one.  This resets the `remaining_deps` to
                // their state at the found level of the `backtrack_stack`.
                trace!("{}[{}]>{} -- no candidates", parent.name(), cur,
                       dep.name());
                match find_candidate(&mut backtrack_stack, &mut cx,
                                     &mut remaining_deps, &mut parent, &mut cur,
                                     &mut dep) {
                    None => return Err(activation_error(&cx, registry, &parent,
                                                        &dep,
                                                        &cx.prev_active(&dep),
                                                        &candidates)),
                    Some(candidate) => candidate,
                }
            }
        };
        trace!("{}[{}]>{} trying {}", parent.name(), cur, dep.name(),
               candidate.version());
        cx.resolve.graph.link(parent.package_id().clone(),
                              candidate.package_id().clone());
        // If we hit an intransitive dependency then clear out the visitation
        // list as we can't induce a cycle through transitive dependencies.
        if !dep.is_transitive() {
            cx.visited.clear();
        }
        remaining_deps.extend(try!(activate(&mut cx, registry,
                                            candidate, &method)));
    }
    trace!("resolved: {:?}", cx.resolve);
    Ok(cx.resolve)
}
fn activate_deps_loop ( mut cx : Context , registry : & mut Registry , top : Rc < Summary > , top_method : & Method ) -> CargoResult < Resolve > { let mut backtrack_stack = Vec :: new ( ) ; let mut remaining_deps = Vec :: new ( ) ; remaining_deps . extend ( try ! ( activate ( mut cx registry top top_method ) ) ) ; // Main resolution loop, this is the workhorse of the resolution algorithm. // // You'll note that a few stacks are maintained on the side, which might // seem odd when this algorithm looks like it could be implemented // recursively. While correct, this is implemented iteratively to avoid // blowing the stack (the recusion depth is proportional to the size of the // input). // // The general sketch of this loop is to run until there are no dependencies // left to activate, and for each dependency to attempt to activate all of // its own dependencies in turn. The `backtrack_stack` is a side table of // backtracking states where if we hit an error we can return to in order to // attempt to continue resolving. while let Some ( mut deps_frame ) = remaining_deps . pop ( ) { let frame = match deps_frame . remaining_siblings . next ( ) { Some ( sibling ) => { let parent = deps_frame . parent . clone ( ) ; remaining_deps . push ( deps_frame ) ; ( parent , sibling ) } None => { cx . visited . remove ( & deps_frame . id ) ; continue } } ; let ( mut parent , ( mut cur , ( mut dep , candidates , features ) ) ) = frame ; assert ! ( remaining_deps is_empty ( ) ) ; let method = Method :: Required { dev_deps : false , features : & features , uses_default_features : dep . uses_default_features ( ) , } ; let my_candidates = { let prev_active = cx . prev_active ( & dep ) ; trace ! ( " " parent name ( ) cur dep name ( ) candidates len ( ) ) ; trace ! ( " " parent name ( ) cur dep name ( ) prev_active len ( ) ) ; // Filter the set of candidates based on the previously activated // versions for this dependency. We can actually use a version if it // precisely matches an activated version or if it is otherwise // incompatible with all other activated versions. Note that we // define "compatible" here in terms of the semver sense where if // the left-most nonzero digit is the same they're considered // compatible. candidates . iter ( ) . filter ( | & b | { prev_active . iter ( ) . any ( | a | a == b ) || prev_active . iter ( ) . all ( | a | { ! compatible ( a . version ( ) , b . version ( ) ) } ) } ) . cloned ( ) . collect ( ) } ; // Alright, for each candidate that's gotten this far, it meets the // following requirements: // // 1. The version matches the dependency requirement listed for this //    package // 2. There are no activated versions for this package which are //    semver-compatible, or there's an activated version which is //    precisely equal to `candidate`. // // This means that we're going to attempt to activate each candidate in // turn. We could possibly fail to activate each candidate, so we try // each one in turn. let mut remaining_candidates = RcVecIter :: new ( my_candidates ) ; let candidate = match remaining_candidates . next ( ) { Some ( ( _ , candidate ) ) => { // We have a candidate. Add an entry to the `backtrack_stack` so // we can try the next one if this one fails. backtrack_stack . push ( BacktrackFrame { context_backup : cx . clone ( ) , deps_backup : remaining_deps . clone ( ) , remaining_candidates : remaining_candidates , parent : parent . clone ( ) , dep : dep . clone ( ) , } ) ; candidate } None => { // This dependency has no valid candidate. Backtrack until we // find a dependency that does have a candidate to try, and try // to activate that one.  This resets the `remaining_deps` to // their state at the found level of the `backtrack_stack`. trace ! ( " " parent name ( ) cur dep name ( ) ) ; match find_candidate ( & mut backtrack_stack , & mut cx , & mut remaining_deps , & mut parent , & mut cur , & mut dep ) { None => return Err ( activation_error ( & cx , registry , & parent , & dep , & cx . prev_active ( & dep ) , & candidates ) ) , Some ( candidate ) => candidate , } } } ; trace ! ( " " parent name ( ) cur dep name ( ) candidate version ( ) ) ; cx . resolve . graph . link ( parent . package_id ( ) . clone ( ) , candidate . package_id ( ) . clone ( ) ) ; // If we hit an intransitive dependency then clear out the visitation // list as we can't induce a cycle through transitive dependencies. if ! dep . is_transitive ( ) { cx . visited . clear ( ) ; } remaining_deps . extend ( try ! ( activate ( mut cx registry candidate method ) ) ) ; } trace ! ( " " cx resolve ) ; Ok ( cx . resolve ) }
Recursively activates the dependencies for `top`, in depth-first order,
backtracking across possible candidates for each dependency as necessary.
Recursively activates the dependencies for ` top ` in depth - first order backtracking across possible candidates for each dependency as necessary .
cx
Context
registry
&mut Registry
top
Rc<Summary>
top_method
&Method
cx
Context
registry
&mut Registry
top
Rc<Summary>
top_method
&Method