Skip to content

Commit e4284dd

Browse files
committed
Add State::add_incompatibility_from_dependencies (#27)
This wrapper avoids accessing the `incompatibility_store` directly in uv code. Before: ```rust let dep_incompats = self.pubgrub.add_version( package.clone(), version.clone(), dependencies, ); self.pubgrub.partial_solution.add_version( package.clone(), version.clone(), dep_incompats, &self.pubgrub.incompatibility_store, ); ``` After: ```rust self.pubgrub.add_incompatibility_from_dependencies(package.clone(), version.clone(), dependencies); ``` `add_incompatibility_from_dependencies` is one of the main methods for the custom interface to pubgrub.
1 parent 0210a99 commit e4284dd

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/internal/core.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,23 @@ impl<DP: DependencyProvider> State<DP> {
7373
}
7474
}
7575

76+
/// Add the dependencies for the current version of the current package as incompatibilities.
77+
pub fn add_package_version_dependencies(
78+
&mut self,
79+
package: Id<DP::P>,
80+
version: DP::V,
81+
dependencies: impl IntoIterator<Item = (DP::P, DP::VS)>,
82+
) {
83+
let dep_incompats =
84+
self.add_incompatibility_from_dependencies(package, version.clone(), dependencies);
85+
self.partial_solution.add_package_version_incompatibilities(
86+
package.clone(),
87+
version.clone(),
88+
dep_incompats,
89+
&self.incompatibility_store,
90+
)
91+
}
92+
7693
/// Add an incompatibility to the state.
7794
pub fn add_incompatibility(&mut self, incompat: Incompatibility<DP::P, DP::VS, DP::M>) {
7895
let id = self.incompatibility_store.alloc(incompat);

src/internal/partial_solution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
375375
/// In practice I think it can only produce a conflict if one of the dependencies
376376
/// (which are used to make the new incompatibilities)
377377
/// is already in the partial solution with an incompatible version.
378-
pub(crate) fn add_version(
378+
pub(crate) fn add_package_version_incompatibilities(
379379
&mut self,
380380
package: Id<DP::P>,
381381
version: DP::V,

src/solver.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,7 @@ pub fn resolve<DP: DependencyProvider>(
171171
};
172172

173173
// Add that package and version if the dependencies are not problematic.
174-
let dep_incompats =
175-
state.add_incompatibility_from_dependencies(p, v.clone(), dependencies);
176-
177-
state
178-
.partial_solution
179-
.add_version(p, v, dep_incompats, &state.incompatibility_store);
174+
state.add_package_version_dependencies(p.clone(), v.clone(), dependencies);
180175
} else {
181176
// `dep_incompats` are already in `incompatibilities` so we know there are not satisfied
182177
// terms and can add the decision directly.

0 commit comments

Comments
 (0)