From cb8827e102d26901673e7653783060a7bf429d52 Mon Sep 17 00:00:00 2001 From: konsti Date: Tue, 2 Jan 2024 20:31:34 +0100 Subject: [PATCH] ci: linter fixes (#173) --- examples/unsat_root_message_no_version.rs | 10 ++++------ src/range.rs | 2 +- tests/proptest.rs | 17 +++++++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/examples/unsat_root_message_no_version.rs b/examples/unsat_root_message_no_version.rs index 7c45b9ee..ac258e34 100644 --- a/examples/unsat_root_message_no_version.rs +++ b/examples/unsat_root_message_no_version.rs @@ -92,13 +92,11 @@ impl ReportFormatter> for CustomReportFormatter } else { format!("{package} {package_set} depends on {dependency}") } + } else if matches!(package, Package::Root) { + // Exclude the dummy version for root packages + format!("{package} depends on {dependency} {dependency_set}") } else { - if matches!(package, Package::Root) { - // Exclude the dummy version for root packages - format!("{package} depends on {dependency} {dependency_set}") - } else { - format!("{package} {package_set} depends on {dependency} {dependency_set}") - } + format!("{package} {package_set} depends on {dependency} {dependency_set}") } } } diff --git a/src/range.rs b/src/range.rs index e3ba82e2..ab88a0ca 100644 --- a/src/range.rs +++ b/src/range.rs @@ -629,7 +629,7 @@ pub mod tests { segments.push((start_bound, Unbounded)); } - return Range { segments }.check_invariants(); + Range { segments }.check_invariants() }) } diff --git a/tests/proptest.rs b/tests/proptest.rs index d73567a7..24dd64a4 100644 --- a/tests/proptest.rs +++ b/tests/proptest.rs @@ -1,5 +1,7 @@ // SPDX-License-Identifier: MPL-2.0 +#![allow(clippy::type_complexity)] + use std::collections::BTreeSet as Set; use std::convert::Infallible; @@ -9,7 +11,9 @@ use pubgrub::range::Range; use pubgrub::report::{DefaultStringReporter, DerivationTree, External, Reporter}; use pubgrub::solver::{resolve, Dependencies, DependencyProvider, OfflineDependencyProvider}; use pubgrub::type_aliases::SelectedDependencies; -use pubgrub::version::{NumberVersion, SemanticVersion}; +use pubgrub::version::NumberVersion; +#[cfg(feature = "serde")] +use pubgrub::version::SemanticVersion; use pubgrub::version_set::VersionSet; use proptest::collection::{btree_map, btree_set, vec}; @@ -115,6 +119,7 @@ fn timeout_resolve>( } type NumVS = Range; +#[cfg(feature = "serde")] type SemVS = Range; #[test] @@ -303,7 +308,7 @@ fn retain_versions( if !retain(n, v) { continue; } - let deps = match dependency_provider.get_dependencies(&n, &v).unwrap() { + let deps = match dependency_provider.get_dependencies(n, v).unwrap() { Dependencies::Unknown => panic!(), Dependencies::Known(deps) => deps, }; @@ -327,7 +332,7 @@ fn retain_dependencies( let mut smaller_dependency_provider = OfflineDependencyProvider::new(); for n in dependency_provider.packages() { for v in dependency_provider.versions(n).unwrap() { - let deps = match dependency_provider.get_dependencies(&n, &v).unwrap() { + let deps = match dependency_provider.get_dependencies(n, v).unwrap() { Dependencies::Unknown => panic!(), Dependencies::Known(deps) => deps, }; @@ -543,7 +548,7 @@ proptest! { // If resolution was successful, then unpublishing a version of a crate // that was not selected should not change that. let smaller_dependency_provider = retain_versions(&dependency_provider, |n, v| { - used.get(&n) == Some(&v) // it was used + used.get(n) == Some(v) // it was used || to_remove.get(&(*n, *v)).is_none() // or it is not one to be removed }); prop_assert!( @@ -588,7 +593,7 @@ fn large_case() { let mut sat = SatResolve::new(&dependency_provider); for p in dependency_provider.packages() { for v in dependency_provider.versions(p).unwrap() { - let res = resolve(&dependency_provider, p.clone(), v); + let res = resolve(&dependency_provider, *p, v); sat.check_resolve(&res, p, v); } } @@ -598,7 +603,7 @@ fn large_case() { let mut sat = SatResolve::new(&dependency_provider); for p in dependency_provider.packages() { for v in dependency_provider.versions(p).unwrap() { - let res = resolve(&dependency_provider, p.clone(), v); + let res = resolve(&dependency_provider, *p, v); sat.check_resolve(&res, p, v); } }