Skip to content

Commit

Permalink
Fix serde and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dewert99 committed Dec 10, 2024
1 parent 81cc122 commit dc73314
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
6 changes: 2 additions & 4 deletions src/egraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,12 +850,10 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {

let did_merge = self.analysis.merge(&mut info.data1.data, info.data2.data);
if did_merge.0 {
self.analysis_pending
.extend(info.parents1.into_iter().copied());
self.analysis_pending.extend(info.parents1.iter().copied());
}
if did_merge.1 {
self.analysis_pending
.extend(info.parents2.into_iter().copied());
self.analysis_pending.extend(info.parents2.iter().copied());
}

concat_vecs(&mut info.data1.nodes, info.data2.nodes);
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ impl std::fmt::Display for Id {
mod cid {
/// Index into the classes field of an [`EGraph`]
#[derive(Hash, Clone, Copy, Eq, PartialEq)]
#[cfg_attr(feature = "serde-1", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde-1", serde(transparent))]
pub struct ClassId(pub(crate) u32);

impl std::fmt::Debug for ClassId {
Expand Down
11 changes: 7 additions & 4 deletions src/raw/egraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ impl<L: Language, D, U: UndoLogT<L, D>> RawEGraph<L, D, U> {
}

/// Similar to [`raw_add`](RawEGraph::raw_add) but takes an extra `pre_union`
/// closure that allows comparing the two [equal](Eq::eq) canonical nodes used to determine
/// closure that allows comparing the two [equal](PartialEq::eq) canonical nodes used to determine
/// a congruent union. This can be useful in niche situations involving explanations when
/// node canonization sorts children to make some discriminants symmetric
///
Expand Down Expand Up @@ -750,12 +750,15 @@ impl<L: Language, D, U: UndoLogT<L, D>> RawEGraph<L, D, U> {
let _: Result<(), Infallible> = RawEGraph::try_raw_rebuild(
outer,
get_self,
|this, id1, id2| Ok(perform_union(this, id1, id2)),
|this, id1, id2| {
perform_union(this, id1, id2);
Ok(())
},
handle_pending,
);
}

/// Similar to [`raw_rebuild`] but allows for the union operation to fail and abort the rebuild
/// Similar to [`raw_rebuild`](RawEGraph::raw_rebuild) but allows for the union operation to fail and abort the rebuild
#[inline]
pub fn try_raw_rebuild<T, E>(
outer: &mut T,
Expand All @@ -773,7 +776,7 @@ impl<L: Language, D, U: UndoLogT<L, D>> RawEGraph<L, D, U> {
}

/// Similar to [`try_raw_rebuild`](RawEGraph::try_raw_rebuild) but takes an extra `pre_union`
/// closure that allows comparing the two [equal](Eq::eq) canonical nodes used to determine
/// closure that allows comparing the two [equal](PartialEq::eq) canonical nodes used to determine
/// a congruent union. This can be useful in niche situations involving explanations when
/// node canonization sorts children to make some discriminants symmetric
#[inline]
Expand Down
12 changes: 6 additions & 6 deletions src/raw/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ impl<L: Language> IndexMut<Id> for RecExpr<L> {
}
}

/// Trait that defines a Language whose terms will be in the [`EGraph`].
/// Trait that defines a Language whose terms will be in the [`EGraph`](crate::raw::RawEGraph).
///
/// Check out the [`define_language!`] macro for an easy way to create
/// Check out the [`define_language!`](crate::define_language) macro for an easy way to create
/// a [`Language`].
///
/// If you want to pretty-print expressions, you should implement [`Display`] to
/// If you want to pretty-print expressions, you should implement [`Display`](core::fmt::Display) to
/// display the language node's operator. For example, a language node
/// `Add([Id; 2])` might be displayed as "+".
///
/// To parse expressions from strings you should also implement [`FromOp`].
/// To parse expressions from strings you should also implement [`FromOp`](crate::FromOp).
///
/// The [`define_language!`] macro automatically implements both [`Display`] and
/// [`FromOp`].
/// The [`define_language!`](crate::define_language) macro automatically implements both
/// [`Display`](core::fmt::Display) and [`FromOp`](crate::FromOp).
///
/// See [`SymbolLang`] for quick-and-dirty use cases.
#[allow(clippy::len_without_is_empty)]
Expand Down
1 change: 0 additions & 1 deletion src/raw/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ mod hashmap {
use super::BuildHasher;
pub(crate) type HashMap<K, V> = hashbrown::HashMap<K, V, BuildHasher>;
pub(crate) type HashSet<K> = hashbrown::HashSet<K, BuildHasher>;
pub(crate) type Entry<'a, K, V> = hashbrown::hash_map::Entry<'a, K, V, BuildHasher>;
}

0 comments on commit dc73314

Please sign in to comment.