Clearer desired behaviour with an assertion
authorAidan Hobson Sayers <aidanhs@cantab.net>
Sat, 3 Feb 2018 21:24:22 +0000 (21:24 +0000)
committerAidan Hobson Sayers <aidanhs@cantab.net>
Sat, 3 Feb 2018 21:24:22 +0000 (21:24 +0000)
src/cargo/core/resolver/mod.rs

index 3522df18b3ea7cceb3fdac3123e95c457d338e15..24dab3646229d9ec8fd300f0f34567a8cc3efc7a 100644 (file)
@@ -767,8 +767,11 @@ fn find_candidate<'a>(backtrack_stack: &mut Vec<BacktrackFrame<'a>>,
             (frame.remaining_candidates.next(prev_active),
              frame.remaining_candidates.clone().next(prev_active).is_some())
         };
+        let cur_num_dep_prev_active = frame.context_backup.prev_active(dep).len();
+        // Activations should monotonically decrease during backtracking
+        assert!(cur_num_dep_prev_active <= num_dep_prev_active);
         let maychange = !frame.context_backup.is_active(parent) ||
-            frame.context_backup.prev_active(dep).len() != num_dep_prev_active;
+            cur_num_dep_prev_active != num_dep_prev_active;
         if !maychange {
             continue
         }