From cb0abc3a4337dfbdcb7e33d2140430a3a59d66fb Mon Sep 17 00:00:00 2001 From: Dmitriy Chudnyi Date: Sat, 15 Nov 2025 11:33:27 +0300 Subject: [PATCH 1/2] feat: no intersection possible message upgrade --- crates/lib/src/hydrate.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/lib/src/hydrate.rs b/crates/lib/src/hydrate.rs index 9a69c7f45..0e13e7d4a 100644 --- a/crates/lib/src/hydrate.rs +++ b/crates/lib/src/hydrate.rs @@ -47,7 +47,7 @@ where let node = graph .entry(pkg.project.clone()) .or_insert_with(|| Box::new(Node::new(pkg.clone(), None))); - node.pkg.constraint = intersect_constraints(&node.pkg.constraint, &pkg.constraint)?; + node.pkg.constraint = intersect_constraints(&node.pkg.constraint, &pkg.constraint, &pkg.project)?; stack.push(node.clone()); } @@ -57,7 +57,7 @@ where .entry(child_pkg.project.clone()) .or_insert_with(|| Box::new(Node::new(child_pkg.clone(), Some(current.clone())))); let intersection = - intersect_constraints(&child_node.pkg.constraint, &child_pkg.constraint); + intersect_constraints(&child_node.pkg.constraint, &child_pkg.constraint, &child_pkg.project); if let Ok(constraint) = intersection { child_node.pkg.constraint = constraint; current.children.insert(child_node.pkg.project.clone()); @@ -94,7 +94,7 @@ fn condense(pkgs: &Vec) -> Vec { let mut out: Vec = vec![]; for pkg in pkgs { if let Some(existing) = out.iter_mut().find(|p| p.project == pkg.project) { - existing.constraint = intersect_constraints(&existing.constraint, &pkg.constraint) + existing.constraint = intersect_constraints(&existing.constraint, &pkg.constraint, &pkg.project) .expect("Failed to intersect constraints"); } else { out.push(pkg.clone()); @@ -104,6 +104,6 @@ fn condense(pkgs: &Vec) -> Vec { } /// Intersects two version constraints. -fn intersect_constraints(a: &VersionReq, b: &VersionReq) -> Result> { - a.intersect(b).map_err(|e| e.into()) +fn intersect_constraints(a: &VersionReq, b: &VersionReq, project_name: &str) -> Result> { + a.intersect(b).map_err(|e| format!("{} for {}: {} and {}", e, project_name, a, b).into()) } From 72fc47caa3408fe8bdd420520e0fa35bfdb3cc20 Mon Sep 17 00:00:00 2001 From: Dmitriy Chudnyi Date: Sat, 15 Nov 2025 12:09:53 +0300 Subject: [PATCH 2/2] fix: fmt --- crates/lib/src/hydrate.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/crates/lib/src/hydrate.rs b/crates/lib/src/hydrate.rs index 0e13e7d4a..b54d53591 100644 --- a/crates/lib/src/hydrate.rs +++ b/crates/lib/src/hydrate.rs @@ -47,7 +47,8 @@ where let node = graph .entry(pkg.project.clone()) .or_insert_with(|| Box::new(Node::new(pkg.clone(), None))); - node.pkg.constraint = intersect_constraints(&node.pkg.constraint, &pkg.constraint, &pkg.project)?; + node.pkg.constraint = + intersect_constraints(&node.pkg.constraint, &pkg.constraint, &pkg.project)?; stack.push(node.clone()); } @@ -56,8 +57,11 @@ where let child_node = graph .entry(child_pkg.project.clone()) .or_insert_with(|| Box::new(Node::new(child_pkg.clone(), Some(current.clone())))); - let intersection = - intersect_constraints(&child_node.pkg.constraint, &child_pkg.constraint, &child_pkg.project); + let intersection = intersect_constraints( + &child_node.pkg.constraint, + &child_pkg.constraint, + &child_pkg.project, + ); if let Ok(constraint) = intersection { child_node.pkg.constraint = constraint; current.children.insert(child_node.pkg.project.clone()); @@ -94,8 +98,9 @@ fn condense(pkgs: &Vec) -> Vec { let mut out: Vec = vec![]; for pkg in pkgs { if let Some(existing) = out.iter_mut().find(|p| p.project == pkg.project) { - existing.constraint = intersect_constraints(&existing.constraint, &pkg.constraint, &pkg.project) - .expect("Failed to intersect constraints"); + existing.constraint = + intersect_constraints(&existing.constraint, &pkg.constraint, &pkg.project) + .expect("Failed to intersect constraints"); } else { out.push(pkg.clone()); } @@ -104,6 +109,11 @@ fn condense(pkgs: &Vec) -> Vec { } /// Intersects two version constraints. -fn intersect_constraints(a: &VersionReq, b: &VersionReq, project_name: &str) -> Result> { - a.intersect(b).map_err(|e| format!("{} for {}: {} and {}", e, project_name, a, b).into()) +fn intersect_constraints( + a: &VersionReq, + b: &VersionReq, + project_name: &str, +) -> Result> { + a.intersect(b) + .map_err(|e| format!("{} for {}: {} and {}", e, project_name, a, b).into()) }