Skip to content

Commit

Permalink
fix: fmt and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
tdejager committed Feb 6, 2024
1 parent d76a865 commit ddfba79
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ pub trait DependencyProvider<VS: VersionSet, N: PackageName = String>: Sized {
/// retrieve necessary information from the network, and `await` the returned task handle.
#[allow(async_fn_in_trait)]
async fn sort_candidates(&self, solver: &SolverCache<VS, N, Self>, solvables: &mut [SolvableId]);
async fn sort_candidates(
&self,
solver: &SolverCache<VS, N, Self>,
solvables: &mut [SolvableId],
);

/// Obtains a list of solvables that should be considered when a package with the given name is
/// requested.
Expand Down
2 changes: 1 addition & 1 deletion src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ pub mod tests {
segments.push((start_bound, Unbounded));
}

return Range { segments }.check_invariants();
Range { segments }.check_invariants()
})
}

Expand Down
4 changes: 3 additions & 1 deletion src/solver/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ impl<VS: VersionSet, N: PackageName, D: DependencyProvider<VS, N>> SolverCache<V
// Sort all the candidates in order in which they should be tried by the solver.
let mut sorted_candidates = Vec::new();
sorted_candidates.extend_from_slice(matching_candidates);
self.provider.sort_candidates(self, &mut sorted_candidates).await;
self.provider
.sort_candidates(self, &mut sorted_candidates)
.await;

// If we have a solvable that we favor, we sort that to the front. This ensures
// that the version that is favored is picked first.
Expand Down
4 changes: 2 additions & 2 deletions src/solver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl<VS: VersionSet, N: PackageName + Display, D: DependencyProvider<VS, N>> Sol
// Add clauses for the requirements
let add_requirements = requirements.into_iter().map(|version_set_id| async move {
let dependency_name = self.pool.resolve_version_set_package_name(version_set_id);
self.add_clauses_for_package(&output, dependency_name)
self.add_clauses_for_package(output, dependency_name)
.await?;

// Find all the solvables that match for the given version set
Expand Down Expand Up @@ -321,7 +321,7 @@ impl<VS: VersionSet, N: PackageName + Display, D: DependencyProvider<VS, N>> Sol

let add_constrains = constrains.into_iter().map(|version_set_id| async move {
let dependency_name = self.pool.resolve_version_set_package_name(version_set_id);
self.add_clauses_for_package(&output, dependency_name)
self.add_clauses_for_package(output, dependency_name)
.await?;

// Find all the solvables that match for the given version set
Expand Down
18 changes: 9 additions & 9 deletions tests/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Pack {
}

fn offset(&self, version_offset: i32) -> Pack {
let mut pack = self.clone();
let mut pack = *self;
pack.version = pack.version.wrapping_add_signed(version_offset);
pack
}
Expand Down Expand Up @@ -167,7 +167,7 @@ impl BundleBoxProvider {

pub fn requirements(&self, requirements: &[&str]) -> Vec<VersionSetId> {
requirements
.into_iter()
.iter()
.map(|dep| Spec::from_str(dep).unwrap())
.map(|spec| {
let dep_name = self.pool.intern_package_name(&spec.name);
Expand Down Expand Up @@ -210,13 +210,13 @@ impl BundleBoxProvider {
constrains: &[&str],
) {
let dependencies = dependencies
.into_iter()
.iter()
.map(|dep| Spec::from_str(dep))
.collect::<Result<Vec<_>, _>>()
.unwrap();

let constrains = constrains
.into_iter()
.iter()
.map(|dep| Spec::from_str(dep))
.collect::<Result<Vec<_>, _>>()
.unwrap();
Expand All @@ -239,7 +239,7 @@ impl BundleBoxProvider {
if self.sleep_before_return {
tokio::time::sleep(Duration::from_millis(10)).await;
self.concurrent_requests.fetch_sub(1, Ordering::SeqCst);
return value;
value
} else {
value
}
Expand Down Expand Up @@ -872,8 +872,8 @@ fn test_unsat_constrains() {
("b", 42, vec![]),
]);

provider.add_package("c", 10.into(), &vec![], &vec!["b 0..50"]);
provider.add_package("c", 8.into(), &vec![], &vec!["b 0..50"]);
provider.add_package("c", 10.into(), &[], &["b 0..50"]);
provider.add_package("c", 8.into(), &[], &["b 0..50"]);
let error = solve_unsat(provider, &["a", "c"]);
insta::assert_snapshot!(error);
}
Expand All @@ -888,8 +888,8 @@ fn test_unsat_constrains_2() {
("b", 2, vec!["c 2"]),
]);

provider.add_package("c", 1.into(), &vec![], &vec!["a 3"]);
provider.add_package("c", 2.into(), &vec![], &vec!["a 3"]);
provider.add_package("c", 1.into(), &[], &["a 3"]);
provider.add_package("c", 2.into(), &[], &["a 3"]);
let error = solve_unsat(provider, &["a"]);
insta::assert_snapshot!(error);
}
Expand Down

0 comments on commit ddfba79

Please sign in to comment.