Skip to content

Commit 1392e58

Browse files
authored
fix: constraint formatting (#80)
1 parent f7895f8 commit 1392e58

13 files changed

+52
-558
lines changed

Cargo.lock

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ event-listener = "5.3"
3939
indexmap = "2"
4040
tokio = { version = "1.37", features = ["rt"], optional = true }
4141
async-std = { version = "1.12", default-features = false, features = ["alloc", "default"], optional = true }
42+
version-ranges = { version = "0.1.0", optional = true }
4243

4344
[dev-dependencies]
4445
insta = "1.39.0"
4546
proptest = "1.2"
4647
tracing-test = { version = "0.2.4", features = ["no-env-filter"] }
4748
tokio = { version = "1.35.1", features = ["time", "rt"] }
48-
resolvo = { path = ".", features = ["tokio"] }
49+
resolvo = { path = ".", features = ["tokio", "version-ranges"] }
4950
serde_json = "1.0"

src/conflict.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ use petgraph::{
1111
Direction,
1212
};
1313

14-
use crate::internal::arena::ArenaId;
1514
use crate::{
16-
internal::id::{ClauseId, InternalSolvableId, SolvableId, StringId, VersionSetId},
15+
internal::{
16+
arena::ArenaId,
17+
id::{ClauseId, InternalSolvableId, SolvableId, StringId, VersionSetId},
18+
},
1719
runtime::AsyncRuntime,
1820
solver::{clause::Clause, Solver},
1921
DependencyProvider, Interner, Requirement,
@@ -908,7 +910,7 @@ impl<'i, I: Interner> DisplayUnsat<'i, I> {
908910
let indent = indenter.get_indent();
909911
writeln!(
910912
f,
911-
"{indent}{name} {version_set} , which conflicts with any installable versions previously reported",
913+
"{indent}{name} {version_set}, which conflicts with any installable versions previously reported",
912914
)?;
913915
}
914916
} else {
@@ -985,7 +987,10 @@ impl<'i, I: Interner> fmt::Display for DisplayUnsat<'i, I> {
985987
&ConflictCause::Constrains(version_set_id) => {
986988
writeln!(
987989
f,
988-
"{indent}constraint '{version_set}' cannot be fulfilled",
990+
"{indent}the constraint {name} {version_set} cannot be fulfilled",
991+
name = self
992+
.interner
993+
.display_name(self.interner.version_set_name(version_set_id)),
989994
version_set = self.interner.display_version_set(version_set_id),
990995
)?;
991996
}

src/snapshot.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,7 @@ impl<'s> SnapshotProvider<'s> {
370370

371371
self.additional_version_sets.push(VersionSet {
372372
name,
373-
display: if matcher == "*" {
374-
"*".to_string()
375-
} else {
376-
format!("{} {}", package.name, matcher)
377-
},
373+
display: matcher.to_string(),
378374
matching_candidates,
379375
});
380376

src/solver/cache.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,9 @@ impl<D: DependencyProvider> SolverCache<D> {
242242
}
243243
}
244244

245-
/// Returns the candidates fulfilling the [`Requirement`] sorted from highest to lowest
246-
/// within each version set comprising the [`Requirement`].
245+
/// Returns the candidates fulfilling the [`Requirement`] sorted from
246+
/// highest to lowest within each version set comprising the
247+
/// [`Requirement`].
247248
///
248249
/// If the provider has requested the solving process to be cancelled, the
249250
/// cancellation value will be returned as an `Err(...)`.

src/solver/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -958,10 +958,6 @@ impl<D: DependencyProvider, RT: AsyncRuntime> Solver<D, RT> {
958958
self.negative_assertions
959959
.append(&mut output.negative_assertions);
960960

961-
if let Some(&clause_id) = output.conflicting_clauses.first() {
962-
return Err(clause_id);
963-
}
964-
965961
if let Some(max_name_idx) = output
966962
.new_names
967963
.into_iter()
@@ -973,6 +969,10 @@ impl<D: DependencyProvider, RT: AsyncRuntime> Solver<D, RT> {
973969
}
974970
}
975971

972+
if let Some(&clause_id) = output.conflicting_clauses.first() {
973+
return Err(clause_id);
974+
}
975+
976976
Ok(())
977977
}
978978

src/utils/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
//! implement a custom dependency provider.
33
44
mod pool;
5-
mod range;
65

76
pub use pool::{PackageName, Pool, VersionSet};
8-
pub use range::Range;

src/utils/pool.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,11 @@ impl<VS: VersionSet, N: PackageName> Pool<VS, N> {
187187
self.version_sets[id].0
188188
}
189189

190-
/// Interns a union of two or more version sets and returns its [`VersionSetUnionId`].
190+
/// Interns a union of two or more version sets and returns its
191+
/// [`VersionSetUnionId`].
191192
///
192-
/// Version set unions are *not* deduplicated, and a unique id is returned on every
193-
/// invocation.
193+
/// Version set unions are *not* deduplicated, and a unique id is returned
194+
/// on every invocation.
194195
pub fn intern_version_set_union(
195196
&self,
196197
first: VersionSetId,
@@ -261,3 +262,8 @@ pub trait VersionSet: Clone + Eq + Hash {
261262
/// The element type that is included in the set.
262263
type V: Display;
263264
}
265+
266+
#[cfg(feature = "version-ranges")]
267+
impl<R: Clone + Eq + Hash + Display> VersionSet for version_ranges::Ranges<R> {
268+
type V = R;
269+
}

0 commit comments

Comments
 (0)