Skip to content
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
1 change: 0 additions & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
set -eux

./scripts/fmt.sh --pre-commit
./scripts/hash.sh --pre-commit
./scripts/clippy.sh --pre-commit
./scripts/documentation.sh --pre-commit
./scripts/deny.sh --pre-commit
7 changes: 7 additions & 0 deletions pumpkin-crates/core/clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
disallowed-types = [
{ path = "std::collections::HashSet", reason = "use pumpkin_solver::containers::HashSet" },
{ path = "std::collections::HashMap", reason = "use pumpkin_solver::containers::HashMap" },
{ path = "rand::RngCore", reason = "use pumpkin_solver::basic_types::Random" },
{ path = "rand::Rng", reason = "use pumpkin_solver::basic_types::Random" },
{ path = "rand::SeedableRng", reason = "use pumpkin_solver::basic_types::Random" },
]
12 changes: 12 additions & 0 deletions pumpkin-crates/core/src/basic_types/random.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
use std::fmt::Debug;
use std::ops::Range;

#[allow(
clippy::disallowed_types,
reason = "we implement our random generator using rand"
)]
use rand::Rng;
#[allow(
clippy::disallowed_types,
reason = "we implement our random generator using rand"
)]
use rand::SeedableRng;

use crate::pumpkin_assert_moderate;
Expand Down Expand Up @@ -74,6 +82,10 @@ pub trait Random: Debug {
// We provide a blanket implementation of the trait for any type which implements `SeedableRng`,
// `Rng` and `Debug` to ensure that we can use any "regular" random generator where we expect an
// implementation of Random.
#[allow(
clippy::disallowed_types,
reason = "we implement our random generator using rand"
)]
impl<T> Random for T
where
T: SeedableRng + Rng + Debug,
Expand Down
2 changes: 2 additions & 0 deletions pumpkin-crates/core/src/containers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pub use keyed_vec::*;
pub(crate) use sparse_set::*;

/// [`std::collections::HashMap`] that defaults to a deterministic hasher.
#[allow(clippy::disallowed_types, reason = "this is how we define our HashMap")]
pub type HashMap<K, V, Hasher = FnvBuildHasher> = std::collections::HashMap<K, V, Hasher>;
/// [`std::collections::HashSet`] that defaults to a deterministic hasher.
#[allow(clippy::disallowed_types, reason = "this is how we define our HashSet")]
pub type HashSet<K, Hasher = FnvBuildHasher> = std::collections::HashSet<K, Hasher>;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ use std::collections::VecDeque;
use std::fmt::Debug;
use std::time::Instant;

#[allow(
clippy::disallowed_types,
reason = "any rand generator is a valid implementation of Random"
)]
use rand::SeedableRng;
use rand::rngs::SmallRng;

Expand Down
13 changes: 0 additions & 13 deletions scripts/hash.sh

This file was deleted.