From 7df4f3f6c0de8acf3b4a98db79b98e891ecd42f8 Mon Sep 17 00:00:00 2001 From: Dmitriy Chudnyi Date: Sat, 15 Nov 2025 11:33:27 +0300 Subject: [PATCH 1/3] 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 5ecdd72c5cc538db7bf6481b597aba867ae83358 Mon Sep 17 00:00:00 2001 From: Dmitriy Chudnyi Date: Sat, 15 Nov 2025 12:09:53 +0300 Subject: [PATCH 2/3] 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()) } From fc9d3dad951ba59c3bc13b23a3b188c02a08d779 Mon Sep 17 00:00:00 2001 From: Jacob Heider Date: Mon, 2 Feb 2026 19:49:24 -0500 Subject: [PATCH 3/3] reduce footprint --- crates/lib/src/hydrate.rs | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/crates/lib/src/hydrate.rs b/crates/lib/src/hydrate.rs index b54d53591..cb575604f 100644 --- a/crates/lib/src/hydrate.rs +++ b/crates/lib/src/hydrate.rs @@ -47,8 +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) + .map_err(|e| format!("{} for {}", e, pkg.project))?; stack.push(node.clone()); } @@ -57,11 +57,8 @@ 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); if let Ok(constraint) = intersection { child_node.pkg.constraint = constraint; current.children.insert(child_node.pkg.project.clone()); @@ -72,7 +69,9 @@ where // https://github.com/pkgxdev/pkgx/issues/899 additional_unicodes.push(child_pkg.constraint); } else { - return Err(intersection.unwrap_err()); + return Err( + format!("{} for {}", intersection.unwrap_err(), child_pkg.project).into(), + ); } } } @@ -98,9 +97,8 @@ 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) + .expect("Failed to intersect constraints"); } else { out.push(pkg.clone()); } @@ -109,11 +107,6 @@ 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) -> Result> { + a.intersect(b).map_err(|e| e.into()) }