diff --git a/examples/unsat_root_message_no_version.rs b/examples/unsat_root_message_no_version.rs index 6e133129..80acce7c 100644 --- a/examples/unsat_root_message_no_version.rs +++ b/examples/unsat_root_message_no_version.rs @@ -66,7 +66,7 @@ impl ReportFormatter> for CustomReportFormatter External::NotRoot(package, version) => { format!("we are solving dependencies of {package} {version}") } - External::NoVersions(package, set) => { + External::NoVersions(package, set, _) => { if set == &Range::full() { format!("there is no available version for {package}") } else { diff --git a/src/internal/incompatibility.rs b/src/internal/incompatibility.rs index cddc2892..f471c754 100644 --- a/src/internal/incompatibility.rs +++ b/src/internal/incompatibility.rs @@ -43,8 +43,8 @@ pub type IncompId = Id>; pub enum Kind { /// Initial incompatibility aiming at picking the root package for the first decision. NotRoot(P, VS::V), - /// There are no versions in the given range for this package. - NoVersions(P, VS), + /// There are no versions in the given range for this package. A string reason may be included. + NoVersions(P, VS, Option), /// The package is unavailable for versions in the range. A string reason is included. Unavailable(P, VS, String), /// Incompatibility coming from the dependencies of a given package. @@ -84,14 +84,14 @@ impl Incompatibility { /// Create an incompatibility to remember /// that a given set does not contain any version. - pub fn no_versions(package: P, term: Term) -> Self { + pub fn no_versions(package: P, term: Term, reason: Option) -> Self { let set = match &term { Term::Positive(r) => r.clone(), Term::Negative(_) => panic!("No version should have a positive term"), }; Self { package_terms: SmallMap::One([(package.clone(), term)]), - kind: Kind::NoVersions(package, set), + kind: Kind::NoVersions(package, set, reason), } } @@ -242,9 +242,9 @@ impl Incompatibility { Kind::NotRoot(package, version) => { DerivationTree::External(External::NotRoot(package.clone(), version.clone())) } - Kind::NoVersions(package, set) => { - DerivationTree::External(External::NoVersions(package.clone(), set.clone())) - } + Kind::NoVersions(package, set, reason) => DerivationTree::External( + External::NoVersions(package.clone(), set.clone(), reason.clone()), + ), Kind::Unavailable(package, set, reason) => DerivationTree::External( External::Unavailable(package.clone(), set.clone(), reason.clone()), ), diff --git a/src/report.rs b/src/report.rs index e3ea4ec8..2d8f6a65 100644 --- a/src/report.rs +++ b/src/report.rs @@ -46,8 +46,8 @@ pub enum DerivationTree { pub enum External { /// Initial incompatibility aiming at picking the root package for the first decision. NotRoot(P, VS::V), - /// There are no versions in the given set for this package. - NoVersions(P, VS), + /// There are no versions in the given set for this package. A string reason is included. + NoVersions(P, VS, Option), /// The package is unusable in the given set. A string reason is included. Unavailable(P, VS, String), /// Incompatibility coming from the dependencies of a given package. @@ -81,7 +81,7 @@ impl DerivationTree { packages.insert(p); packages.insert(p2); } - External::NoVersions(p, _) + External::NoVersions(p, _, _) | External::NotRoot(p, _) | External::Unavailable(p, ..) => { packages.insert(p); @@ -109,14 +109,14 @@ impl DerivationTree { DerivationTree::External(_) => {} DerivationTree::Derived(derived) => { match (derived.cause1.deref_mut(), derived.cause2.deref_mut()) { - (DerivationTree::External(External::NoVersions(p, r)), ref mut cause2) => { + (DerivationTree::External(External::NoVersions(p, r, _)), ref mut cause2) => { cause2.collapse_no_versions(); *self = cause2 .clone() .merge_no_versions(p.to_owned(), r.to_owned()) .unwrap_or_else(|| self.to_owned()); } - (ref mut cause1, DerivationTree::External(External::NoVersions(p, r))) => { + (ref mut cause1, DerivationTree::External(External::NoVersions(p, r, _))) => { cause1.collapse_no_versions(); *self = cause1 .clone() @@ -140,9 +140,9 @@ impl DerivationTree { DerivationTree::External(External::NotRoot(_, _)) => { panic!("How did we end up with a NoVersions merged with a NotRoot?") } - DerivationTree::External(External::NoVersions(_, r)) => Some(DerivationTree::External( - External::NoVersions(package, set.union(&r)), - )), + // + // Cannot be merged because the reason may not match + DerivationTree::External(External::NoVersions(_, _, _)) => None, // Cannot be merged because the reason may not match DerivationTree::External(External::Unavailable(_, _, _)) => None, DerivationTree::External(External::FromDependencyOf(p1, r1, p2, r2)) => { @@ -172,7 +172,7 @@ impl fmt::Display for External { Self::NotRoot(package, version) => { write!(f, "we are solving dependencies of {} {}", package, version) } - Self::NoVersions(package, set) => { + Self::NoVersions(package, set, _) => { if set == &VS::full() { write!(f, "there is no available version for {}", package) } else { diff --git a/src/solver.rs b/src/solver.rs index 6bb7f02a..7a6afdcd 100644 --- a/src/solver.rs +++ b/src/solver.rs @@ -128,7 +128,8 @@ pub fn resolve>( // Pick the next compatible version. let v = match decision { None => { - let inc = Incompatibility::no_versions(next.clone(), term_intersection.clone()); + let inc = + Incompatibility::no_versions(next.clone(), term_intersection.clone(), None); state.add_incompatibility(inc); continue; }