Skip to content

Commit dad2b48

Browse files
committed
refactor: dont copy the term for Contradicted
1 parent f0d26a0 commit dad2b48

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/internal/incompatibility.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,16 @@ enum Kind<P: Package, V: Version> {
5252
DerivedFrom(IncompId<P, V>, IncompId<P, V>),
5353
}
5454

55-
/// A type alias for a pair of [Package] and a corresponding [Term].
56-
pub type PackageTerm<P, V> = (P, Term<V>);
57-
5855
/// A Relation describes how a set of terms can be compared to an incompatibility.
5956
/// Typically, the set of terms comes from the partial solution.
6057
#[derive(Eq, PartialEq)]
61-
pub enum Relation<P: Package, V: Version> {
58+
pub enum Relation<P: Package> {
6259
/// We say that a set of terms S satisfies an incompatibility I
6360
/// if S satisfies every term in I.
6461
Satisfied,
6562
/// We say that S contradicts I
6663
/// if S contradicts at least one term in I.
67-
Contradicted(PackageTerm<P, V>),
64+
Contradicted(P),
6865
/// If S satisfies all but one of I's terms and is inconclusive for the remaining term,
6966
/// we say S "almost satisfies" I and we call the remaining term the "unsatisfied term".
7067
AlmostSatisfied(P),
@@ -166,13 +163,13 @@ impl<P: Package, V: Version> Incompatibility<P, V> {
166163
}
167164

168165
/// CF definition of Relation enum.
169-
pub fn relation(&self, mut terms: impl FnMut(&P) -> Option<Term<V>>) -> Relation<P, V> {
166+
pub fn relation(&self, mut terms: impl FnMut(&P) -> Option<Term<V>>) -> Relation<P> {
170167
let mut relation = Relation::Satisfied;
171168
for (package, incompat_term) in self.package_terms.iter() {
172169
match terms(package).map(|term| incompat_term.relation_with(&term)) {
173170
Some(term::Relation::Satisfied) => {}
174171
Some(term::Relation::Contradicted) => {
175-
return Relation::Contradicted((package.clone(), incompat_term.clone()));
172+
return Relation::Contradicted(package.clone());
176173
}
177174
None | Some(term::Relation::Inconclusive) => {
178175
// If a package is not present, the intersection is the same as [Term::any].

src/internal/partial_solution.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl<P: Package, V: Version> PartialSolution<P, V> {
169169
}
170170

171171
/// Check if the terms in the partial solution satisfy the incompatibility.
172-
pub fn relation(&mut self, incompat: &Incompatibility<P, V>) -> Relation<P, V> {
172+
pub fn relation(&mut self, incompat: &Incompatibility<P, V>) -> Relation<P> {
173173
incompat.relation(|package| self.memory.term_intersection_for_package(package).cloned())
174174
}
175175

0 commit comments

Comments
 (0)