-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an UnusableDependencies
incompatibility kind and use for conflicting versions
#424
Changes from 1 commit
8e4f468
ada2226
8058ae8
465ab74
5535a54
dccc87f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,8 @@ pub enum External<P: Package, VS: VersionSet> { | |
NoVersions(P, VS), | ||
/// Dependencies of the package are unavailable for versions in that set. | ||
UnavailableDependencies(P, VS), | ||
/// Dependencies of the package are unusable for versions in that set. | ||
UnusableDependencies(P, VS, Option<String>), | ||
/// Incompatibility coming from the dependencies of a given package. | ||
FromDependencyOf(P, VS, P, VS), | ||
} | ||
|
@@ -113,6 +115,13 @@ impl<P: Package, VS: VersionSet> DerivationTree<P, VS> { | |
DerivationTree::External(External::UnavailableDependencies(_, r)) => Some( | ||
DerivationTree::External(External::UnavailableDependencies(package, set.union(&r))), | ||
), | ||
DerivationTree::External(External::UnusableDependencies(_, r, reason)) => { | ||
Some(DerivationTree::External(External::UnusableDependencies( | ||
package, | ||
set.union(&r), | ||
reason, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👀 this is probably not quite right because we shouldn't merge the reasons here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you say a bit more about this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure it matters, but this merges the two incompatibilities by taking the union of their version ranges and one of the reasons but if the reasons are different we should not merge them because they are distinct incompatibilities. Or.. we could merge them and say "{reason} and {reason}" but that seems unclear later on since you lose the reason for each range. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or we could make the reason it's own enum with its own merge semantics, but that requires encoding the set of reasons in the PubGrub crate. |
||
))) | ||
} | ||
DerivationTree::External(External::FromDependencyOf(p1, r1, p2, r2)) => { | ||
if p1 == package { | ||
Some(DerivationTree::External(External::FromDependencyOf( | ||
|
@@ -158,6 +167,29 @@ impl<P: Package, VS: VersionSet> fmt::Display for External<P, VS> { | |
) | ||
} | ||
} | ||
Self::UnusableDependencies(package, set, reason) => { | ||
if let Some(reason) = reason { | ||
if set == &VS::full() { | ||
write!(f, "dependencies of {} are unusable: {reason}", package) | ||
} else { | ||
write!( | ||
f, | ||
"dependencies of {} at version {} are unusable: {reason}", | ||
package, set | ||
) | ||
} | ||
} else { | ||
if set == &VS::full() { | ||
write!(f, "dependencies of {} are unusable", package) | ||
} else { | ||
write!( | ||
f, | ||
"dependencies of {} at version {} are unusable", | ||
package, set | ||
) | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems generic enough that it could feasibly be upstreamed 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
Self::FromDependencyOf(p, set_p, dep, set_dep) => { | ||
if set_p == &VS::full() && set_dep == &VS::full() { | ||
write!(f, "{} depends on {}", p, dep) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line breaks here make me read this like a haiku 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too haha I just kept the existing style but it's funny