Skip to content

Commit a8a79b4

Browse files
committed
change age to count edges not just activations
A pub dep conflict can be made by connecting two already activated pids
1 parent 2d29734 commit a8a79b4

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/cargo/core/resolver/context.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub use super::resolve::Resolve;
2323
// possible.
2424
#[derive(Clone)]
2525
pub struct Context {
26+
pub age: ContextAge,
2627
pub activations: Activations,
2728
/// list the features that are activated for each package
2829
pub resolve_features: im_rc::HashMap<PackageId, FeaturesSet>,
@@ -82,6 +83,7 @@ impl PackageId {
8283
impl Context {
8384
pub fn new(check_public_visible_dependencies: bool) -> Context {
8485
Context {
86+
age: 0,
8587
resolve_features: im_rc::HashMap::new(),
8688
links: im_rc::HashMap::new(),
8789
public_dependency: if check_public_visible_dependencies {
@@ -108,7 +110,7 @@ impl Context {
108110
parent: Option<(&Summary, &Dependency)>,
109111
) -> ActivateResult<bool> {
110112
let id = summary.package_id();
111-
let age: ContextAge = self.age();
113+
let age: ContextAge = self.age;
112114
match self.activations.entry(id.as_activations_key()) {
113115
im_rc::hashmap::Entry::Occupied(o) => {
114116
debug_assert_eq!(
@@ -180,13 +182,6 @@ impl Context {
180182
})
181183
}
182184

183-
/// Returns the `ContextAge` of this `Context`.
184-
/// For now we use (len of activations) as the age.
185-
/// See the `ContextAge` docs for more details.
186-
pub fn age(&self) -> ContextAge {
187-
self.activations.len()
188-
}
189-
190185
/// If the package is active returns the `ContextAge` when it was added
191186
pub fn is_active(&self, id: PackageId) -> Option<ContextAge> {
192187
self.activations

src/cargo/core/resolver/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ fn activate_deps_loop(
218218
trace!(
219219
"{}[{}]>{} {} candidates",
220220
parent.name(),
221-
cx.age(),
221+
cx.age,
222222
dep.package_name(),
223223
candidates.len()
224224
);
@@ -264,7 +264,7 @@ fn activate_deps_loop(
264264
trace!(
265265
"{}[{}]>{} -- no candidates",
266266
parent.name(),
267-
cx.age(),
267+
cx.age,
268268
dep.package_name()
269269
);
270270

@@ -375,7 +375,7 @@ fn activate_deps_loop(
375375
trace!(
376376
"{}[{}]>{} trying {}",
377377
parent.name(),
378-
cx.age(),
378+
cx.age,
379379
dep.package_name(),
380380
candidate.version()
381381
);
@@ -525,7 +525,7 @@ fn activate_deps_loop(
525525
trace!(
526526
"{}[{}]>{} skipping {} ",
527527
parent.name(),
528-
cx.age(),
528+
cx.age,
529529
dep.package_name(),
530530
pid.version()
531531
);
@@ -594,6 +594,7 @@ fn activate(
594594
opts: ResolveOpts,
595595
) -> ActivateResult<Option<(DepsFrame, Duration)>> {
596596
let candidate_pid = candidate.package_id();
597+
cx.age += 1;
597598
if let Some((parent, dep)) = parent {
598599
let parent_pid = parent.package_id();
599600
Rc::make_mut(
@@ -947,7 +948,7 @@ fn find_candidate(
947948
// make any progress. As a result if we hit this condition we can
948949
// completely skip this backtrack frame and move on to the next.
949950
if let Some(age) = age {
950-
if frame.context.age() > age {
951+
if frame.context.age >= age {
951952
trace!(
952953
"{} = \"{}\" skip as not solving {}: {:?}",
953954
frame.dep.package_name(),

0 commit comments

Comments
 (0)