Make Debug on ProgramInfo optional

This commit is contained in:
2026-05-05 12:29:25 -06:00
parent c883f02738
commit a8f7f93c78

View File

@@ -46,7 +46,8 @@ use serde::{Deserialize, Serialize};
// TODO: write more top-level docs // TODO: write more top-level docs
// TODO: reintroduce validation logic // TODO: reintroduce validation logic
#[derive_where(Clone, Debug, PartialEq, Eq)] #[derive_where(Clone, PartialEq, Eq)]
#[derive_where(Debug; T: DebugProgramInfo)]
#[derive_where(PartialOrd, Ord; T: OrdProgramInfo)] #[derive_where(PartialOrd, Ord; T: OrdProgramInfo)]
#[derive_where(Hash; T: HashProgramInfo)] #[derive_where(Hash; T: HashProgramInfo)]
#[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))] #[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))]
@@ -60,7 +61,8 @@ pub struct Program<T: ProgramInfo> {
pub symbols: Vec<T::SymbolMeta>, pub symbols: Vec<T::SymbolMeta>,
} }
#[derive_where(Clone, Debug, PartialEq, Eq)] #[derive_where(Clone, PartialEq, Eq)]
#[derive_where(Debug; T: DebugProgramInfo)]
#[derive_where(PartialOrd, Ord; T: OrdProgramInfo)] #[derive_where(PartialOrd, Ord; T: OrdProgramInfo)]
#[derive_where(Hash; T: HashProgramInfo)] #[derive_where(Hash; T: HashProgramInfo)]
#[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))] #[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))]
@@ -86,7 +88,8 @@ pub struct Relation<T: ProgramInfo> {
pub rules: Vec<Rule<T>>, pub rules: Vec<Rule<T>>,
} }
#[derive_where(Clone, Debug, PartialEq, Eq)] #[derive_where(Clone, PartialEq, Eq)]
#[derive_where(Debug; T: DebugProgramInfo)]
#[derive_where(PartialOrd, Ord; T: OrdProgramInfo)] #[derive_where(PartialOrd, Ord; T: OrdProgramInfo)]
#[derive_where(Hash; T: HashProgramInfo)] #[derive_where(Hash; T: HashProgramInfo)]
#[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))] #[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))]
@@ -101,7 +104,8 @@ pub struct Rule<T: ProgramInfo> {
pub body: RuleBody<T>, pub body: RuleBody<T>,
} }
#[derive_where(Clone, Debug, PartialEq, Eq)] #[derive_where(Clone, PartialEq, Eq)]
#[derive_where(Debug; T: DebugProgramInfo)]
#[derive_where(PartialOrd, Ord; T: OrdProgramInfo)] #[derive_where(PartialOrd, Ord; T: OrdProgramInfo)]
#[derive_where(Hash; T: HashProgramInfo)] #[derive_where(Hash; T: HashProgramInfo)]
#[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))] #[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))]
@@ -116,7 +120,8 @@ pub struct Assumption<T: ProgramInfo> {
pub body: RuleBody<T>, pub body: RuleBody<T>,
} }
#[derive_where(Clone, Debug, PartialEq, Eq)] #[derive_where(Clone, PartialEq, Eq)]
#[derive_where(Debug; T: DebugProgramInfo)]
#[derive_where(PartialOrd, Ord; T: OrdProgramInfo)] #[derive_where(PartialOrd, Ord; T: OrdProgramInfo)]
#[derive_where(Hash; T: HashProgramInfo)] #[derive_where(Hash; T: HashProgramInfo)]
#[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))] #[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))]
@@ -143,7 +148,8 @@ pub struct RuleBody<T: ProgramInfo> {
/// backend. With a top-down approach, the expression nodes are used to constrain some /// backend. With a top-down approach, the expression nodes are used to constrain some
/// query, but with a bottom-up approach, the expression nodes are used directly to /// query, but with a bottom-up approach, the expression nodes are used directly to
/// produce new sets of results from their children. /// produce new sets of results from their children.
#[derive_where(Clone, Debug, PartialEq, Eq)] #[derive_where(Clone, PartialEq, Eq)]
#[derive_where(Debug; T: DebugProgramInfo)]
#[derive_where(PartialOrd, Ord; T: OrdProgramInfo)] #[derive_where(PartialOrd, Ord; T: OrdProgramInfo)]
#[derive_where(Hash; T: HashProgramInfo)] #[derive_where(Hash; T: HashProgramInfo)]
#[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))] #[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))]
@@ -156,7 +162,8 @@ pub struct Expr<T: ProgramInfo> {
} }
/// An expression node variant. See [Expr]. /// An expression node variant. See [Expr].
#[derive_where(Clone, Debug, PartialEq, Eq)] #[derive_where(Clone, PartialEq, Eq)]
#[derive_where(Debug; T: DebugProgramInfo)]
#[derive_where(PartialOrd, Ord; T: OrdProgramInfo)] #[derive_where(PartialOrd, Ord; T: OrdProgramInfo)]
#[derive_where(Hash; T: HashProgramInfo)] #[derive_where(Hash; T: HashProgramInfo)]
#[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))] #[cfg_attr(feature = "serde", derive_where(Deserialize, Serialize; T: SerdeProgramInfo))]
@@ -436,9 +443,9 @@ pub trait ProgramInfo {
} }
/// A blanket trait bounding all associated types in [ProgramInfo]. /// A blanket trait bounding all associated types in [ProgramInfo].
pub trait Info: Clone + Debug + Eq {} pub trait Info: Clone + Eq {}
impl<T: Clone + Debug + Eq> Info for T {} impl<T: Clone + Eq> Info for T {}
/// Creates a new trait to further bound the members of [ProgramInfo]. /// Creates a new trait to further bound the members of [ProgramInfo].
macro_rules! def_bound_info { macro_rules! def_bound_info {
@@ -476,6 +483,7 @@ macro_rules! def_bound_info {
}; };
} }
def_bound_info!(DebugProgramInfo, Debug);
def_bound_info!(OrdProgramInfo, Ord); def_bound_info!(OrdProgramInfo, Ord);
def_bound_info!(HashProgramInfo, Hash); def_bound_info!(HashProgramInfo, Hash);