From ba85ac4b247a0a8688b0735546dff8bea7281e1a Mon Sep 17 00:00:00 2001 From: Jacob Finkelman Date: Mon, 2 Oct 2023 16:14:32 +0000 Subject: [PATCH] refactor: make CI green --- src/internal/arena.rs | 2 +- src/internal/partial_solution.rs | 6 +++--- src/package.rs | 6 +++--- src/report.rs | 4 ++-- src/solver.rs | 8 ++++---- tests/proptest.rs | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/internal/arena.rs b/src/internal/arena.rs index 75d04c82..7b4fc160 100644 --- a/src/internal/arena.rs +++ b/src/internal/arena.rs @@ -55,7 +55,7 @@ impl Id { } fn from(n: u32) -> Self { Self { - raw: n as u32, + raw: n, _ty: PhantomData, } } diff --git a/src/internal/partial_solution.rs b/src/internal/partial_solution.rs index 23960a45..1b683b9d 100644 --- a/src/internal/partial_solution.rs +++ b/src/internal/partial_solution.rs @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MPL-2.0 //! A Memory acts like a structured partial solution -//! where terms are regrouped by package in a [Map](crate::type_aliases::Map). +//! where terms are regrouped by package in a [Map]. use std::fmt::Display; @@ -147,7 +147,7 @@ impl PartialSolution { } } self.current_decision_level = self.current_decision_level.increment(); - let mut pa = self + let pa = self .package_assignments .get_mut(&package) .expect("Derivations must already exist"); @@ -177,7 +177,7 @@ impl PartialSolution { self.next_global_index += 1; match self.package_assignments.entry(package) { Entry::Occupied(mut occupied) => { - let mut pa = occupied.get_mut(); + let pa = occupied.get_mut(); pa.highest_decision_level = self.current_decision_level; match &mut pa.assignments_intersection { // Check that add_derivation is never called in the wrong context. diff --git a/src/package.rs b/src/package.rs index e36b91ed..36c6069e 100644 --- a/src/package.rs +++ b/src/package.rs @@ -2,16 +2,16 @@ //! Trait for identifying packages. //! Automatically implemented for traits implementing -//! [Clone] + [Eq] + [Hash] + [Debug] + [Display](std::fmt::Display). +//! [Clone] + [Eq] + [Hash] + [Debug] + [Display]. use std::fmt::{Debug, Display}; use std::hash::Hash; /// Trait for identifying packages. /// Automatically implemented for types already implementing -/// [Clone] + [Eq] + [Hash] + [Debug] + [Display](std::fmt::Display). +/// [Clone] + [Eq] + [Hash] + [Debug] + [Display]. pub trait Package: Clone + Eq + Hash + Debug + Display {} /// Automatically implement the Package trait for any type -/// that already implement [Clone] + [Eq] + [Hash] + [Debug] + [Display](std::fmt::Display). +/// that already implement [Clone] + [Eq] + [Hash] + [Debug] + [Display]. impl Package for T {} diff --git a/src/report.rs b/src/report.rs index 94db9c3c..ff0b2d3f 100644 --- a/src/report.rs +++ b/src/report.rs @@ -197,7 +197,7 @@ impl DefaultStringReporter { fn build_recursive(&mut self, derived: &Derived) { self.build_recursive_helper(derived); if let Some(id) = derived.shared_id { - if self.shared_with_ref.get(&id) == None { + if self.shared_with_ref.get(&id).is_none() { self.add_line_ref(); self.shared_with_ref.insert(id, self.ref_count); } @@ -260,7 +260,7 @@ impl DefaultStringReporter { // and finally conclude. (None, None) => { self.build_recursive(derived1); - if derived1.shared_id != None { + if derived1.shared_id.is_some() { self.lines.push("".into()); self.build_recursive(current); } else { diff --git a/src/solver.rs b/src/solver.rs index 275ba1d9..3962f3d5 100644 --- a/src/solver.rs +++ b/src/solver.rs @@ -27,8 +27,8 @@ //! //! The algorithm is generic and works for any type of dependency system //! as long as packages (P) and versions (V) implement -//! the [Package](crate::package::Package) and [Version](crate::version::Version) traits. -//! [Package](crate::package::Package) is strictly equivalent and automatically generated +//! the [Package] and [Version](crate::version::Version) traits. +//! [Package] is strictly equivalent and automatically generated //! for any type that implement [Clone] + [Eq] + [Hash] + [Debug] + [Display](std::fmt::Display). //! [Version](crate::version::Version) simply states that versions are ordered, //! that there should be @@ -298,13 +298,13 @@ where { let count_valid = |(p, set): &(T, U)| { list_available_versions(p.borrow()) - .filter(|v| set.borrow().contains(v.borrow())) + .filter(|v| set.borrow().contains(v)) .count() }; let (pkg, set) = potential_packages .min_by_key(count_valid) .expect("potential_packages gave us an empty iterator"); - let version = list_available_versions(pkg.borrow()).find(|v| set.borrow().contains(v.borrow())); + let version = list_available_versions(pkg.borrow()).find(|v| set.borrow().contains(v)); (pkg, version) } diff --git a/tests/proptest.rs b/tests/proptest.rs index 8ec22e80..34c84c97 100644 --- a/tests/proptest.rs +++ b/tests/proptest.rs @@ -507,7 +507,7 @@ fn large_case() { let mut sat = SatResolve::new(&dependency_provider); for p in dependency_provider.packages() { for n in dependency_provider.versions(p).unwrap() { - if let Ok(s) = resolve(&dependency_provider, p.clone(), n.clone()) { + if let Ok(s) = resolve(&dependency_provider, p, n.clone()) { assert!(sat.sat_is_valid_solution(&s)); } else { assert!(!sat.sat_resolve(p, &n));