Repository navigation
Description
Problem
The doc comment on Ident<State> in src/simlin-engine/src/common.rs (lines 2264-2273 at HEAD) says:
The derived
PartialEq/Eq/Hash/Ord/PartialOrd/salsa::Updatedelegate to that handle's manual impls (value equality, value-based hash consistent withBorrow<str>, lexicographic ordering), preserving the previousString-backed semantics.
For salsa::Update this delegation cannot happen. Salsa 0.26's derive macro adds a salsa::Update bound to every type parameter (add_trait_bounds in salsa-macros' src/update.rs:154-158, verified in the vendored salsa-macros-0.26.2 source), so the generated impl is:
unsafe impl<State: salsa::Update> salsa::Update for Ident<State> { ... }The Canonical marker type (common.rs ~2257) derives only Debug/Clone/Copy/PartialEq/Eq/Hash/PartialOrd/Ord -- no salsa::Update -- so Ident<Canonical>: salsa::Update is never satisfiable. A compile probe confirms: asserting the bound yields E0277 ("the trait bound common::Canonical: salsa::Update is not satisfied").
What actually happens (sound, but not what the comment says)
An Ident<Canonical> field inside a larger #[derive(salsa::Update)] type resolves through salsa's autoref-specialization fallback (salsa::update::helper::Dispatch<T> with the Fallback impl for T: 'static + PartialEq, which calls update_fallback: compare via PartialEq, overwrite, report changed iff different). Because Ident's derived PartialEq bottoms out in CanonicalStorage's value-correct pointer equality, the fallback is behaviorally equivalent to the manual CanonicalStorage::maybe_update -- so this is a documentation inaccuracy, not a correctness bug. But the comment claims a delegation path that does not exist.
Note the related claim on CanonicalStorage itself (common.rs ~204-208, "the public newtypes keep #[derive(salsa::Update)], whose per-field dispatch finds this impl") IS accurate for the non-generic newtypes -- only the generic Ident<State> is affected, because only it picks up the added type-parameter bound.
Why it matters
Anyone reasoning about salsa invalidation semantics from these docs (e.g. auditing maybe_update behavior for backdating) will be misled into thinking the manual impl runs for Ident<Canonical> fields. The soundness argument for the current behavior (PartialEq fallback is value-correct here) is real but undocumented.
Component
src/simlin-engine/src/common.rs(Ident<State>,Canonical/Rawmarkers)
Possible fixes (small doc/cleanup item)
- Correct the comment: state that the derived
salsa::Updateimpl onIdent<State>is unsatisfiable forCanonical/Raw(noUpdateimpl on the markers) and that containers resolveIdent<Canonical>fields through salsa's'static + PartialEqcompare-and-replace fallback, which is value-correct viaCanonicalStorage'sPartialEq; or - Give the
Canonical/Rawmarker types trivialsalsa::Updateimpls (sound: the onlyState-typed field isPhantomData<State>), making the derived impl genuinely usable so the delegation the comment describes actually happens. Then per-field dispatch oninner: CanonicalStoragedoes find the manual impl.
Option 2 plus a one-line comment tweak is probably cleanest; either way the comment should stop claiming a delegation that cannot occur.
Discovery context
Found during a review of salsa::Update derives on branch steelman-first-boxes (2026-07-17); the inaccuracy is pre-existing on main. Verified against vendored salsa-macros-0.26.2/salsa-0.26.2 sources and an E0277 compile probe.
Activity