Skip to content

Commit 9b2295d

Browse files
committed
cargo fmt
1 parent 2b1f093 commit 9b2295d

File tree

3 files changed

+55
-25
lines changed

3 files changed

+55
-25
lines changed

src/cargo/core/resolver/conflict_cache.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::collections::{HashMap, HashSet};
22

3-
use core::{Dependency, PackageId};
4-
use core::resolver::Context;
53
use super::types::ConflictReason;
4+
use core::resolver::Context;
5+
use core::{Dependency, PackageId};
66

77
pub(super) struct ConflictCache {
88
// `con_from_dep` is a cache of the reasons for each time we
@@ -77,11 +77,17 @@ impl ConflictCache {
7777
/// `dep` is known to be unresolvable if
7878
/// all the `PackageId` entries are activated
7979
pub fn insert(&mut self, dep: &Dependency, con: &HashMap<PackageId, ConflictReason>) {
80-
let past = self.con_from_dep
80+
let past = self
81+
.con_from_dep
8182
.entry(dep.clone())
8283
.or_insert_with(Vec::new);
8384
if !past.contains(con) {
84-
trace!("{} = \"{}\" adding a skip {:?}", dep.package_name(), dep.version_req(), con);
85+
trace!(
86+
"{} = \"{}\" adding a skip {:?}",
87+
dep.package_name(),
88+
dep.version_req(),
89+
con
90+
);
8591
past.push(con.clone());
8692
for c in con.keys() {
8793
self.dep_from_pid

src/cargo/core/resolver/mod.rs

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,12 @@ fn activate_deps_loop(
305305
// It's our job here to backtrack, if possible, and find a
306306
// different candidate to activate. If we can't find any
307307
// candidates whatsoever then it's time to bail entirely.
308-
trace!("{}[{}]>{} -- no candidates", parent.name(), cur, dep.package_name());
308+
trace!(
309+
"{}[{}]>{} -- no candidates",
310+
parent.name(),
311+
cur,
312+
dep.package_name()
313+
);
309314

310315
// Use our list of `conflicting_activations` to add to our
311316
// global list of past conflicting activations, effectively
@@ -325,7 +330,12 @@ fn activate_deps_loop(
325330
past_conflicting_activations.insert(&dep, &conflicting_activations);
326331
}
327332

328-
match find_candidate(&mut backtrack_stack, &parent, backtracked, &conflicting_activations) {
333+
match find_candidate(
334+
&mut backtrack_stack,
335+
&parent,
336+
backtracked,
337+
&conflicting_activations,
338+
) {
329339
Some((candidate, has_another, frame)) => {
330340
// Reset all of our local variables used with the
331341
// contents of `frame` to complete our backtrack.
@@ -432,8 +442,7 @@ fn activate_deps_loop(
432442
.clone()
433443
.filter_map(|(_, (ref new_dep, _, _))| {
434444
past_conflicting_activations.conflicting(&cx, new_dep)
435-
})
436-
.next()
445+
}).next()
437446
{
438447
// If one of our deps is known unresolvable
439448
// then we will not succeed.
@@ -467,18 +476,14 @@ fn activate_deps_loop(
467476
.iter()
468477
.flat_map(|other| other.flatten())
469478
// for deps related to us
470-
.filter(|&(_, ref other_dep)|
471-
known_related_bad_deps.contains(other_dep))
472-
.filter_map(|(other_parent, other_dep)| {
479+
.filter(|&(_, ref other_dep)| {
480+
known_related_bad_deps.contains(other_dep)
481+
}).filter_map(|(other_parent, other_dep)| {
473482
past_conflicting_activations
474-
.find_conflicting(
475-
&cx,
476-
&other_dep,
477-
|con| con.contains_key(&pid)
478-
)
479-
.map(|con| (other_parent, con))
480-
})
481-
.next()
483+
.find_conflicting(&cx, &other_dep, |con| {
484+
con.contains_key(&pid)
485+
}).map(|con| (other_parent, con))
486+
}).next()
482487
{
483488
let rel = conflict.get(&pid).unwrap().clone();
484489

@@ -837,7 +842,13 @@ fn find_candidate(
837842
.context_backup
838843
.is_conflicting(Some(parent.package_id()), conflicting_activations)
839844
{
840-
trace!("{} = \"{}\" skip as not solving {}: {:?}", frame.dep.package_name(), frame.dep.version_req(), parent.package_id(), conflicting_activations);
845+
trace!(
846+
"{} = \"{}\" skip as not solving {}: {:?}",
847+
frame.dep.package_name(),
848+
frame.dep.version_req(),
849+
parent.package_id(),
850+
conflicting_activations
851+
);
841852
continue;
842853
}
843854
}

tests/testsuite/resolve.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,12 @@ fn resolving_with_constrained_sibling_transitive_dep_effects() {
964964
}
965965

966966
#[test]
967-
fn dont_yet_know_the_problem() {
967+
fn incomplete_information_skiping() {
968+
// When backtracking due to a failed dependency, if Cargo is
969+
// trying to be clever and skip irrelevant dependencies, care must
970+
// be taken to not miss the transitive effects of alternatives.
971+
// Fuzzing discovered that for some reason cargo was skiping based
972+
// on incomplete information in the following case:
968973
// minimized bug found in:
969974
// https://github.com/rust-lang/cargo/commit/003c29b0c71e5ea28fbe8e72c148c755c9f3f8d9
970975
let input = vec![
@@ -1007,10 +1012,13 @@ fn dont_yet_know_the_problem() {
10071012
assert!(resolve(&pkg_id("root"), vec![dep("g")], &new_reg).is_ok());
10081013
}
10091014

1010-
10111015
#[test]
1012-
fn dont_yet_know_the_problem_2() {
1013-
// minimized bug found in:
1016+
fn incomplete_information_skiping_2() {
1017+
// When backtracking due to a failed dependency, if Cargo is
1018+
// trying to be clever and skip irrelevant dependencies, care must
1019+
// be taken to not miss the transitive effects of alternatives.
1020+
// Fuzzing discovered that for some reason cargo was skiping based
1021+
// on incomplete information in the following case:
10141022
// https://github.com/rust-lang/cargo/commit/003c29b0c71e5ea28fbe8e72c148c755c9f3f8d9
10151023
let input = vec![
10161024
pkg!(("b", "3.8.10")),
@@ -1074,7 +1082,12 @@ fn dont_yet_know_the_problem_2() {
10741082
}
10751083

10761084
#[test]
1077-
fn dont_yet_know_the_problem_3() {
1085+
fn incomplete_information_skiping_3() {
1086+
// When backtracking due to a failed dependency, if Cargo is
1087+
// trying to be clever and skip irrelevant dependencies, care must
1088+
// be taken to not miss the transitive effects of alternatives.
1089+
// Fuzzing discovered that for some reason cargo was skiping based
1090+
// on incomplete information in the following case:
10781091
// minimized bug found in:
10791092
// https://github.com/rust-lang/cargo/commit/003c29b0c71e5ea28fbe8e72c148c755c9f3f8d9
10801093
let input = vec![

0 commit comments

Comments
 (0)