diff --git a/src/eclass.rs b/src/eclass.rs index e235d58e..fdb47f0b 100644 --- a/src/eclass.rs +++ b/src/eclass.rs @@ -35,6 +35,7 @@ impl EClass { } /// 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() } diff --git a/src/egraph.rs b/src/egraph.rs index e35e3787..9ff10c1e 100644 --- a/src/egraph.rs +++ b/src/egraph.rs @@ -707,11 +707,7 @@ impl> EGraph { 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) } diff --git a/src/explain.rs b/src/explain.rs index c25f6ba2..76ae5e4e 100644 --- a/src/explain.rs +++ b/src/explain.rs @@ -1074,7 +1074,7 @@ impl Explain { equalities } - pub(crate) fn with_raw_egraph<'a, X>(&'a mut self, raw: X) -> ExplainWith<'a, L, X> { + pub(crate) fn with_raw_egraph(&mut self, raw: X) -> ExplainWith<'_, L, X> { ExplainWith { explain: self, raw } } } diff --git a/src/raw/dhashmap.rs b/src/raw/dhashmap.rs index ec847c42..bc2ac8eb 100644 --- a/src/raw/dhashmap.rs +++ b/src/raw/dhashmap.rs @@ -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: &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(hasher: &S) -> impl Fn(&(K, V, DHMIdx)) -> u64 + '_ { move |x| hash_one(hasher, &x.0) } impl DHashMap { #[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)), @@ -136,7 +134,7 @@ impl FromIterator<(K, V)> for DHashMa fn from_iter>(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 @@ -158,6 +156,7 @@ mod test { #[derive(Eq, PartialEq, Debug, Clone)] struct BadHash(T); + #[allow(clippy::derive_hash_xor_eq)] // We explicitly want to test a bad implementation impl Hash for BadHash { fn hash(&self, _: &mut H) {} } diff --git a/src/raw/semi_persistent2.rs b/src/raw/semi_persistent2.rs index 982b8a5d..3e321e9a 100644 --- a/src/raw/semi_persistent2.rs +++ b/src/raw/semi_persistent2.rs @@ -166,7 +166,7 @@ impl> RawEGraph { 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) {