Skip to content

Make egglog-bridge a private Cargo dependency #932

Description

@oflatt-claude

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

  1. 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>())
  2. ColumnTy: already re-exported as pub use egglog_bridge::ColumnTy — this stays as-is (re-exports from private deps are fine).

  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions