Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: constraint formatting #80

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ event-listener = "5.3"
indexmap = "2"
tokio = { version = "1.37", features = ["rt"], optional = true }
async-std = { version = "1.12", default-features = false, features = ["alloc", "default"], optional = true }
version-ranges = { version = "0.1.0", optional = true }

[dev-dependencies]
insta = "1.39.0"
proptest = "1.2"
tracing-test = { version = "0.2.4", features = ["no-env-filter"] }
tokio = { version = "1.35.1", features = ["time", "rt"] }
resolvo = { path = ".", features = ["tokio"] }
resolvo = { path = ".", features = ["tokio", "version-ranges"] }
serde_json = "1.0"
13 changes: 9 additions & 4 deletions src/conflict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ use petgraph::{
Direction,
};

use crate::internal::arena::ArenaId;
use crate::{
internal::id::{ClauseId, InternalSolvableId, SolvableId, StringId, VersionSetId},
internal::{
arena::ArenaId,
id::{ClauseId, InternalSolvableId, SolvableId, StringId, VersionSetId},
},
runtime::AsyncRuntime,
solver::{clause::Clause, Solver},
DependencyProvider, Interner, Requirement,
Expand Down Expand Up @@ -908,7 +910,7 @@ impl<'i, I: Interner> DisplayUnsat<'i, I> {
let indent = indenter.get_indent();
writeln!(
f,
"{indent}{name} {version_set} , which conflicts with any installable versions previously reported",
"{indent}{name} {version_set}, which conflicts with any installable versions previously reported",
)?;
}
} else {
Expand Down Expand Up @@ -985,7 +987,10 @@ impl<'i, I: Interner> fmt::Display for DisplayUnsat<'i, I> {
&ConflictCause::Constrains(version_set_id) => {
writeln!(
f,
"{indent}constraint '{version_set}' cannot be fulfilled",
"{indent}the constraint {name} {version_set} cannot be fulfilled",
name = self
.interner
.display_name(self.interner.version_set_name(version_set_id)),
version_set = self.interner.display_version_set(version_set_id),
)?;
}
Expand Down
6 changes: 1 addition & 5 deletions src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,7 @@ impl<'s> SnapshotProvider<'s> {

self.additional_version_sets.push(VersionSet {
name,
display: if matcher == "*" {
"*".to_string()
} else {
format!("{} {}", package.name, matcher)
},
display: matcher.to_string(),
matching_candidates,
});

Expand Down
5 changes: 3 additions & 2 deletions src/solver/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,9 @@ impl<D: DependencyProvider> SolverCache<D> {
}
}

/// Returns the candidates fulfilling the [`Requirement`] sorted from highest to lowest
/// within each version set comprising the [`Requirement`].
/// Returns the candidates fulfilling the [`Requirement`] sorted from
/// highest to lowest within each version set comprising the
/// [`Requirement`].
///
/// If the provider has requested the solving process to be cancelled, the
/// cancellation value will be returned as an `Err(...)`.
Expand Down
8 changes: 4 additions & 4 deletions src/solver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,10 +958,6 @@ impl<D: DependencyProvider, RT: AsyncRuntime> Solver<D, RT> {
self.negative_assertions
.append(&mut output.negative_assertions);

if let Some(&clause_id) = output.conflicting_clauses.first() {
return Err(clause_id);
}

if let Some(max_name_idx) = output
.new_names
.into_iter()
Expand All @@ -973,6 +969,10 @@ impl<D: DependencyProvider, RT: AsyncRuntime> Solver<D, RT> {
}
}

if let Some(&clause_id) = output.conflicting_clauses.first() {
return Err(clause_id);
}

Ok(())
}

Expand Down
2 changes: 0 additions & 2 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
//! implement a custom dependency provider.

mod pool;
mod range;

pub use pool::{PackageName, Pool, VersionSet};
pub use range::Range;
12 changes: 9 additions & 3 deletions src/utils/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ impl<VS: VersionSet, N: PackageName> Pool<VS, N> {
self.version_sets[id].0
}

/// Interns a union of two or more version sets and returns its [`VersionSetUnionId`].
/// Interns a union of two or more version sets and returns its
/// [`VersionSetUnionId`].
///
/// Version set unions are *not* deduplicated, and a unique id is returned on every
/// invocation.
/// Version set unions are *not* deduplicated, and a unique id is returned
/// on every invocation.
pub fn intern_version_set_union(
&self,
first: VersionSetId,
Expand Down Expand Up @@ -261,3 +262,8 @@ pub trait VersionSet: Clone + Eq + Hash {
/// The element type that is included in the set.
type V: Display;
}

#[cfg(feature = "version-ranges")]
impl<R: Clone + Eq + Hash + Display> VersionSet for version_ranges::Ranges<R> {
type V = R;
}
Loading
Loading