Skip to content

Commit

Permalink
Make optional
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Feb 3, 2024
1 parent e807e92 commit 0aa134a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/unsat_root_message_no_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl ReportFormatter<Package, Range<SemanticVersion>> 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 {
Expand Down
6 changes: 3 additions & 3 deletions src/internal/incompatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ pub type IncompId<P, VS> = Id<Incompatibility<P, VS>>;
pub enum Kind<P: Package, VS: VersionSet> {
/// 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. A string reason is included.
NoVersions(P, VS, String),
/// There are no versions in the given range for this package. A string reason may be included.
NoVersions(P, VS, Option<String>),
/// 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.
Expand Down Expand Up @@ -84,7 +84,7 @@ impl<P: Package, VS: VersionSet> Incompatibility<P, VS> {

/// Create an incompatibility to remember
/// that a given set does not contain any version.
pub fn no_versions(package: P, term: Term<VS>, reason: String) -> Self {
pub fn no_versions(package: P, term: Term<VS>, reason: Option<String>) -> Self {
let set = match &term {
Term::Positive(r) => r.clone(),
Term::Negative(_) => panic!("No version should have a positive term"),
Expand Down
2 changes: 1 addition & 1 deletion src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub enum External<P: Package, VS: VersionSet> {
/// 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. A string reason is included.
NoVersions(P, VS, String),
NoVersions(P, VS, Option<String>),
/// 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.
Expand Down
7 changes: 2 additions & 5 deletions src/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,8 @@ pub fn resolve<P: Package, VS: VersionSet, DP: DependencyProvider<P, VS>>(
// Pick the next compatible version.
let v = match decision {
None => {
let inc = Incompatibility::no_versions(
next.clone(),
term_intersection.clone(),
"no compatible versions".to_string(),
);
let inc =
Incompatibility::no_versions(next.clone(), term_intersection.clone(), None);
state.add_incompatibility(inc);
continue;
}
Expand Down

0 comments on commit 0aa134a

Please sign in to comment.