Skip to content

Commit 2459aa4

Browse files
mpizenbergEh2406
authored andcommitted
refactor: a tiny cleanup change (#93)
1 parent 7eeee70 commit 2459aa4

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/solver.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,19 @@ pub fn resolve<P: Package, V: Version>(
112112
next = decision.0.clone();
113113

114114
// Pick the next compatible version.
115+
let term_intersection = state
116+
.partial_solution
117+
.term_intersection_for_package(&next)
118+
.expect("a package was chosen but we don't have a term.");
115119
let v = match decision.1 {
116120
None => {
117-
let term = state
118-
.partial_solution
119-
.term_intersection_for_package(&next)
120-
.expect("a package was chosen but we don't have a term.")
121-
.clone();
122-
state.add_incompatibility(Incompatibility::no_versions(next.clone(), term.clone()));
121+
let inc = Incompatibility::no_versions(next.clone(), term_intersection.clone());
122+
state.add_incompatibility(inc);
123123
continue;
124124
}
125125
Some(x) => x,
126126
};
127-
if !state
128-
.partial_solution
129-
.term_intersection_for_package(&next)
130-
.expect("a package was chosen but we don't have a term.")
131-
.contains(&v)
132-
{
127+
if !term_intersection.contains(&v) {
133128
return Err(PubGrubError::ErrorChoosingPackageVersion(
134129
"choose_package_version picked an incompatible version".into(),
135130
));
@@ -179,6 +174,8 @@ pub fn resolve<P: Package, V: Version>(
179174
let dep_incompats =
180175
state.add_incompatibility_from_dependencies(p.clone(), v.clone(), &dependencies);
181176

177+
// TODO: I don't think this check can actually happen.
178+
// We might want to put it under #[cfg(debug_assertions)].
182179
if state.incompatibility_store[dep_incompats.clone()]
183180
.iter()
184181
.any(|incompat| state.is_terminal(incompat))

0 commit comments

Comments
 (0)