Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
dewert99 committed Feb 12, 2024
1 parent 8649cdb commit 34091d0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/eclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl<L, D> EClass<L, D> {
}

/// Returns the number of enodes in this eclass.
#[allow(clippy::len_without_is_empty)] // https://github.com/rust-lang/rust-clippy/issues/11165
pub fn len(&self) -> usize {
self.nodes.len()
}
Expand Down
6 changes: 1 addition & 5 deletions src/egraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,11 +707,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
enode,
|this, existing_id, enode| {
if let Some(explain) = this.explain.as_mut() {
if let Some(existing_id) = explain.uncanon_memo.get(enode) {
Some(*existing_id)
} else {
None
}
explain.uncanon_memo.get(enode).copied()
} else {
Some(existing_id)
}
Expand Down
2 changes: 1 addition & 1 deletion src/explain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ impl<L: Language> Explain<L> {
equalities
}

pub(crate) fn with_raw_egraph<'a, X>(&'a mut self, raw: X) -> ExplainWith<'a, L, X> {
pub(crate) fn with_raw_egraph<X>(&mut self, raw: X) -> ExplainWith<'_, L, X> {
ExplainWith { explain: self, raw }
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/raw/dhashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,19 @@ fn hash_one(hasher: &impl BuildHasher, hash: impl Hash) -> u64 {
}

#[inline]
fn eq<'a, K: Eq, V>(k: &'a K) -> impl Fn(&(K, V, DHMIdx)) -> bool + 'a {
fn eq<K: Eq, V>(k: &K) -> impl Fn(&(K, V, DHMIdx)) -> bool + '_ {
move |x| &x.0 == k
}

#[inline]
fn hasher_fn<'a, K: Hash, V, S: BuildHasher>(
hasher: &'a S,
) -> impl Fn(&(K, V, DHMIdx)) -> u64 + 'a {
fn hasher_fn<K: Hash, V, S: BuildHasher>(hasher: &S) -> impl Fn(&(K, V, DHMIdx)) -> u64 + '_ {
move |x| hash_one(hasher, &x.0)
}

impl<K: Hash + Eq, V, S: BuildHasher> DHashMap<K, V, S> {
#[inline]
pub(super) fn entry(&mut self, k: K) -> (Entry<'_, K, V>, u64) {
let hash = hash_one(&mut self.hasher, &k);
let hash = hash_one(&self.hasher, &k);
let len = self.data.len() as DHMIdx;
let entry = match self.data.entry(hash, eq(&k), hasher_fn(&self.hasher)) {
hash_table::Entry::Occupied(entry) => Entry::Occupied((k, &mut entry.into_mut().1)),
Expand Down Expand Up @@ -136,7 +134,7 @@ impl<K: Hash + Eq, V, S: Default + BuildHasher> FromIterator<(K, V)> for DHashMa
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
let mut res = Self::default();
iter.into_iter().for_each(|(k, v)| {
let hash = hash_one(&mut res.hasher, &k);
let hash = hash_one(&res.hasher, &k);
res.insert_with_hash(hash, k, v)
});
res
Expand All @@ -158,6 +156,7 @@ mod test {
#[derive(Eq, PartialEq, Debug, Clone)]
struct BadHash<T>(T);

#[allow(clippy::derive_hash_xor_eq)] // We explicitly want to test a bad implementation
impl<T> Hash for BadHash<T> {
fn hash<H: Hasher>(&self, _: &mut H) {}
}
Expand Down
2 changes: 1 addition & 1 deletion src/raw/semi_persistent2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl<L: Language, D, U: AsUnwrap<UndoLog>> RawEGraph<L, D, U> {
self.pop_memo2(memo_log_count);
self.pop_parents2(pop_parents_count, node_count);
self.pop_unions2(union_count, node_count, state, clear, mk_data, handle_eqv);
self.pop_nodes2(usize::from(node_count));
self.pop_nodes2(node_count);
}

fn pop_memo2(&mut self, old_count: usize) {
Expand Down

0 comments on commit 34091d0

Please sign in to comment.