Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
baszalmstra committed Nov 2, 2023
1 parent a86ddea commit 52dd63b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mod solver;

use itertools::Itertools;

use crate::internal::id::StringId;
pub use internal::{
id::{NameId, SolvableId, VersionSetId},
mapping::Mapping,
Expand All @@ -30,7 +31,6 @@ use std::{
fmt::{Debug, Display},
hash::Hash,
};
use crate::internal::id::StringId;

/// The solver is based around the fact that for for every package name we are trying to find a
/// single variant. Variants are grouped by their respective package name. A package name is
Expand Down Expand Up @@ -143,8 +143,8 @@ pub trait SolvableDisplay<VS: VersionSet, Name: PackageName = String> {
pub struct DefaultSolvableDisplay;

impl<VS: VersionSet, Name: Hash + Eq> SolvableDisplay<VS, Name> for DefaultSolvableDisplay
where
VS::V: Ord,
where
VS::V: Ord,
{
fn display_candidates(
&self,
Expand Down
11 changes: 5 additions & 6 deletions src/pool.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fmt::{Display, Formatter};

use crate::internal::id::StringId;
use crate::{
internal::{
arena::Arena,
Expand All @@ -9,7 +10,6 @@ use crate::{
solvable::{InternalSolvable, Solvable},
PackageName, VersionSet,
};
use crate::internal::id::StringId;

/// A pool that stores data related to the available packages.
///
Expand Down Expand Up @@ -65,8 +65,7 @@ impl<VS: VersionSet, N: PackageName> Pool<VS, N> {

/// Interns a generic string into the `Pool` and returns its `StringId`. Strings are
/// deduplicated.
pub fn intern_string(&self, name: impl Into<String> + AsRef<str>) -> StringId
{
pub fn intern_string(&self, name: impl Into<String> + AsRef<str>) -> StringId {
if let Some(id) = self.string_to_ids.get_copy(name.as_ref()) {
return id;
}
Expand All @@ -89,9 +88,9 @@ impl<VS: VersionSet, N: PackageName> Pool<VS, N> {
///
/// The original name can be resolved using the [`Self::resolve_package_name`] function.
pub fn intern_package_name<NValue>(&self, name: NValue) -> NameId
where
NValue: Into<N>,
N: Clone,
where
NValue: Into<N>,
N: Clone,
{
let name = name.into();
if let Some(id) = self.names_to_ids.get_copy(&name) {
Expand Down
2 changes: 1 addition & 1 deletion src/problem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ impl<VS: VersionSet, N: PackageName + Display, M: SolvableDisplay<VS, N>> fmt::D
.display_candidates(self.pool, &[solvable_id])
)?;
}
&ConflictCause::Disabled(solvable_id, _) => continue,
ConflictCause::Disabled(_, _) => continue,
};
}
}
Expand Down
9 changes: 2 additions & 7 deletions tests/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,20 +799,15 @@ fn test_disabled() {

#[test]
fn test_merge_disabled() {
let mut provider = BundleBoxProvider::from_packages(&[
("a", 1, vec![]),
("a", 2, vec![]),
]);
let mut provider = BundleBoxProvider::from_packages(&[("a", 1, vec![]), ("a", 2, vec![])]);
provider.set_disabled("a", 1, "it is externally disabled");
provider.set_disabled("a", 2, "it is externally disabled");
insta::assert_snapshot!(solve_snapshot(provider, &["a"]));
}

#[test]
fn test_root_disabled() {
let mut provider = BundleBoxProvider::from_packages(&[
("a", 1, vec![]),
]);
let mut provider = BundleBoxProvider::from_packages(&[("a", 1, vec![])]);
provider.set_disabled("a", 1, "it is externally disabled");
insta::assert_snapshot!(solve_snapshot(provider, &["a"]));
}

0 comments on commit 52dd63b

Please sign in to comment.