Currently egglog-bridge is an implicit public dependency of egglog, meaning downstream users can (and sometimes must) reference egglog_bridge::* types directly. This is unintentional — egglog-bridge is an internal implementation crate.
Cargo supports public = false on dependencies (stabilized in 1.84), which causes the compiler to error if a private dep's types appear in the public API without being explicitly re-exported. We should use this to enforce the boundary.
What needs to change
-
Sort trait (src/sort/mod.rs): column_ty and register_type take &egglog_bridge::EGraph / &mut egglog_bridge::EGraph. These need to take an egglog-owned wrapper type (e.g. SortBackend) that forwards the two operations custom sorts actually need:
register_base_type::<T>() → backend.base_values_mut().register_type::<T>()
register_container_type::<T>() → backend.register_container_ty::<T>()
base_column_ty::<T>() → ColumnTy::Base(backend.base_values().get_ty::<T>())
-
ColumnTy: already re-exported as pub use egglog_bridge::ColumnTy — this stays as-is (re-exports from private deps are fine).
-
Cargo.toml: add public = false to the egglog-bridge dep in the egglog crate, then fix whatever the compiler flags.
Motivation
A recent review caught egglog_bridge::ScanEntry leaking into the public CostModel::enode_cost signature (fixed in #901). public = false would have caught this statically at compile time. This is a breaking API change to Sort but a small one, and it means users of custom sorts no longer need to know egglog-bridge exists.
Currently
egglog-bridgeis an implicit public dependency ofegglog, meaning downstream users can (and sometimes must) referenceegglog_bridge::*types directly. This is unintentional —egglog-bridgeis an internal implementation crate.Cargo supports
public = falseon dependencies (stabilized in 1.84), which causes the compiler to error if a private dep's types appear in the public API without being explicitly re-exported. We should use this to enforce the boundary.What needs to change
Sorttrait (src/sort/mod.rs):column_tyandregister_typetake&egglog_bridge::EGraph/&mut egglog_bridge::EGraph. These need to take anegglog-owned wrapper type (e.g.SortBackend) that forwards the two operations custom sorts actually need:register_base_type::<T>()→backend.base_values_mut().register_type::<T>()register_container_type::<T>()→backend.register_container_ty::<T>()base_column_ty::<T>()→ColumnTy::Base(backend.base_values().get_ty::<T>())ColumnTy: already re-exported aspub use egglog_bridge::ColumnTy— this stays as-is (re-exports from private deps are fine).Cargo.toml: addpublic = falseto theegglog-bridgedep in theegglogcrate, then fix whatever the compiler flags.Motivation
A recent review caught
egglog_bridge::ScanEntryleaking into the publicCostModel::enode_costsignature (fixed in #901).public = falsewould have caught this statically at compile time. This is a breaking API change toSortbut a small one, and it means users of custom sorts no longer need to knowegglog-bridgeexists.