@@ -112,24 +112,19 @@ pub fn resolve<P: Package, V: Version>(
112
112
next = decision. 0 . clone ( ) ;
113
113
114
114
// 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." ) ;
115
119
let v = match decision. 1 {
116
120
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) ;
123
123
continue ;
124
124
}
125
125
Some ( x) => x,
126
126
} ;
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) {
133
128
return Err ( PubGrubError :: ErrorChoosingPackageVersion (
134
129
"choose_package_version picked an incompatible version" . into ( ) ,
135
130
) ) ;
@@ -179,6 +174,8 @@ pub fn resolve<P: Package, V: Version>(
179
174
let dep_incompats =
180
175
state. add_incompatibility_from_dependencies ( p. clone ( ) , v. clone ( ) , & dependencies) ;
181
176
177
+ // TODO: I don't think this check can actually happen.
178
+ // We might want to put it under #[cfg(debug_assertions)].
182
179
if state. incompatibility_store [ dep_incompats. clone ( ) ]
183
180
. iter ( )
184
181
. any ( |incompat| state. is_terminal ( incompat) )
0 commit comments