diff --git a/crates/lib/src/hydrate.rs b/crates/lib/src/hydrate.rs index 9a69c7f45..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)?; + 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); + 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) - .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) -> 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()) }