From: Aidan Hobson Sayers Date: Tue, 5 Dec 2017 21:08:40 +0000 (+0000) Subject: Don't incorrectly compute cur from binary heap X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~4^2~31^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1c3bba34dbfc38cfe96285051c1494d0f4a703b6;p=cargo.git Don't incorrectly compute cur from binary heap --- diff --git a/Cargo.toml b/Cargo.toml index 76ce4d803..21a9cf053 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,3 +72,6 @@ hamcrest = "=0.1.1" name = "cargo" test = false doc = false + +[profile.release] +overflow-checks = true diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index bc299f333..9ce0a9e2f 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -474,10 +474,6 @@ impl RcVecIter { vec: vec, } } - - fn cur_index(&self) -> usize { - self.rest.start - 1 - } } // Not derived to avoid `T: Clone` @@ -548,6 +544,7 @@ impl Ord for DepsFrame { } struct BacktrackFrame<'a> { + cur: usize, context_backup: Context<'a>, deps_backup: BinaryHeap, remaining_candidates: RemainingCandidates, @@ -692,6 +689,7 @@ fn activate_deps_loop<'a>(mut cx: Context<'a>, // we can try the next one if this one fails. if has_another { backtrack_stack.push(BacktrackFrame { + cur, context_backup: Context::clone(&cx), deps_backup: >::clone(&remaining_deps), remaining_candidates: remaining_candidates, @@ -759,6 +757,7 @@ fn find_candidate<'a>(backtrack_stack: &mut Vec>, frame.remaining_candidates.clone().next(prev_active).is_some()) }; if let Some(candidate) = next { + *cur = frame.cur; if has_another { *cx = frame.context_backup.clone(); *remaining_deps = frame.deps_backup.clone(); @@ -773,7 +772,6 @@ fn find_candidate<'a>(backtrack_stack: &mut Vec>, *dep = frame.dep; *features = frame.features; } - *cur = remaining_deps.peek().unwrap().remaining_siblings.cur_index(); return Some(candidate) } }