if we are just here_for the error_messages then only try the last candidate
authorEh2406 <YeomanYaacov@gmail.com>
Fri, 9 Mar 2018 19:34:45 +0000 (14:34 -0500)
committerEh2406 <YeomanYaacov@gmail.com>
Mon, 12 Mar 2018 02:21:38 +0000 (22:21 -0400)
src/cargo/core/resolver/mod.rs
tests/testsuite/resolve.rs

index c557697b50db8cfc30d7b478a675d65a519aad1f..77a69fdca321942d0fa5f0d7bb757d6f1b882136 100644 (file)
@@ -853,6 +853,15 @@ fn activate_deps_loop(
         trace!("{}[{}]>{} {} candidates", parent.name(), cur, dep.name(), candidates.len());
         trace!("{}[{}]>{} {} prev activations", parent.name(), cur, dep.name(), cx.prev_active(&dep).len());
 
+        let just_here_for_the_error_messages = past_conflicting_activations.get(&dep).and_then(|past_bad| {
+            past_bad.iter().find(|conflicting| {
+                conflicting
+                    .iter()
+                    // note: a lot of redundant work in is_active for similar debs
+                    .all(|(con, _)| cx.is_active(con))
+            })
+        }).is_some();
+
         let mut remaining_candidates = RemainingCandidates::new(&candidates);
         let mut successfully_activated = false;
         let mut backtracked = false;
@@ -881,7 +890,7 @@ fn activate_deps_loop(
                 trace!("{}[{}]>{} -- no candidates", parent.name(), cur, dep.name());
 
                 let past = past_conflicting_activations.entry(dep.clone()).or_insert_with(Vec::new);
-                if !past.contains(&conflicting_activations) {
+                if !just_here_for_the_error_messages && !past.contains(&conflicting_activations) {
                     trace!("{}[{}]>{} adding a skip {:?}", parent.name(), cur, dep.name(), conflicting_activations);
                     past.push(conflicting_activations.clone());
                 }
@@ -916,6 +925,10 @@ fn activate_deps_loop(
                 })
             })?;
 
+            if just_here_for_the_error_messages && !backtracked && has_another {
+                continue
+            }
+
             // We have a candidate. Clone a `BacktrackFrame`
             // so we can add it to the `backtrack_stack` if activation succeeds.
             // We clone now in case `activate` changes `cx` and then fails.
@@ -947,19 +960,21 @@ fn activate_deps_loop(
 
             match res {
                 Ok(Some((frame, dur))) => {
-                    let mut has_past_conflicting_dep = false;
-                    if let Some(conflicting) = frame.remaining_siblings.clone().filter_map(|(_, (deb, _, _))| {
-                        past_conflicting_activations.get(&deb).and_then(|past_bad| {
-                            past_bad.iter().find(|conflicting| {
-                                conflicting
-                                    .iter()
-                                    // note: a lot of redundant work in is_active for similar debs
-                                    .all(|(con, _)| cx.is_active(con) || *con == pid)
+                    let mut has_past_conflicting_dep = just_here_for_the_error_messages && !backtracked;
+                    if !has_past_conflicting_dep {
+                        if let Some(conflicting) = frame.remaining_siblings.clone().filter_map(|(_, (deb, _, _))| {
+                            past_conflicting_activations.get(&deb).and_then(|past_bad| {
+                                past_bad.iter().find(|conflicting| {
+                                    conflicting
+                                        .iter()
+                                        // note: a lot of redundant work in is_active for similar debs
+                                        .all(|(con, _)| cx.is_active(con) || *con == pid)
+                                })
                             })
-                        })
-                    }).next() {
-                        conflicting_activations.extend(conflicting.clone());
-                        has_past_conflicting_dep = true;
+                        }).next() {
+                            conflicting_activations.extend(conflicting.clone());
+                            has_past_conflicting_dep = true;
+                        }
                     }
                     if !has_another && has_past_conflicting_dep && !backtracked {
                         // we have not activated ANY candidates and
index 327eadca8bfabb6922681c854573429c47e9174e..8c96da9dd357d13b2e49daa37175e3e6fc980049 100644 (file)
@@ -474,8 +474,8 @@ fn resolving_with_many_equivalent_backtracking() {
         pkg!(("level0", "1.0.0")),
     ];
 
-    const DEPTH: usize = 100;
-    const BRANCHING_FACTOR: usize = 10;
+    const DEPTH: usize = 200;
+    const BRANCHING_FACTOR: usize = 100;
 
     for l in 0..DEPTH {
         let name = format!("level{}", l);