Skip to content

Commit 357a64d

Browse files
authored
fix: merge nodes more aggressively when unsat (#27)
1 parent da56fa5 commit 357a64d

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

src/problem.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ pub enum ConflictCause {
248248
/// - They all have the same name
249249
/// - They all have the same predecessor nodes
250250
/// - They all have the same successor nodes
251-
/// - None of them have incoming conflicting edges
252251
pub(crate) struct MergedProblemNode {
253252
pub ids: Vec<SolvableId>,
254253
}
@@ -370,14 +369,6 @@ impl ProblemGraph {
370369
}
371370
};
372371

373-
if graph
374-
.edges_directed(node_id, Direction::Incoming)
375-
.any(|e| matches!(e.weight(), ProblemEdge::Conflict(..)))
376-
{
377-
// Nodes that are the target of a conflict should never be merged
378-
continue;
379-
}
380-
381372
let predecessors: Vec<_> = graph
382373
.edges_directed(node_id, Direction::Incoming)
383374
.map(|e| e.source())
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
source: tests/solver.rs
3+
expression: "solve_snapshot(provider, &[\"a 0..3\", \"a 3..5\"])"
4+
---
5+
The following packages are incompatible
6+
|-- a >=3, <5 can be installed with any of the following options:
7+
|-- a 3 | 4
8+
|-- a >=0, <3 cannot be installed because there are no viable options:
9+
|-- a 1 | 2, which conflicts with the versions reported above.
10+

tests/snapshots/solver__unsat_constrains_2.snap

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
---
22
source: tests/solver.rs
3-
assertion_line: 703
43
expression: error
54
---
65
The following packages are incompatible
76
|-- a * cannot be installed because there are no viable options:
8-
|-- a 2 would require
9-
|-- b *, which cannot be installed because there are no viable options:
10-
|-- b 2 would require
11-
|-- c >=2, <3, which cannot be installed because there are no viable options:
12-
|-- c 2 would constrain
13-
|-- a >=3, <4 , which conflicts with any installable versions previously reported
14-
|-- b 1 would require
15-
|-- c >=1, <2, which cannot be installed because there are no viable options:
16-
|-- c 1 would constrain
17-
|-- a >=3, <4 , which conflicts with any installable versions previously reported
18-
|-- a 1 would require
7+
|-- a 1 | 2 would require
198
|-- b *, which cannot be installed because there are no viable options:
209
|-- b 2 would require
2110
|-- c >=2, <3, which cannot be installed because there are no viable options:

tests/solver.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,17 @@ fn test_merge_excluded() {
912912
insta::assert_snapshot!(solve_snapshot(provider, &["a"]));
913913
}
914914

915+
#[test]
916+
fn test_merge_installable() {
917+
let provider = BundleBoxProvider::from_packages(&[
918+
("a", 1, vec![]),
919+
("a", 2, vec![]),
920+
("a", 3, vec![]),
921+
("a", 4, vec![]),
922+
]);
923+
insta::assert_snapshot!(solve_snapshot(provider, &["a 0..3", "a 3..5"]));
924+
}
925+
915926
#[test]
916927
fn test_root_excluded() {
917928
let mut provider = BundleBoxProvider::from_packages(&[("a", 1, vec![])]);

0 commit comments

Comments
 (0)