Skip to content

refactor(ethexe): replace manual fmt::Display/Debug impls with derive_more#5521

Draft
grishasobol wants to merge 1 commit into
gear-tech:masterfrom
grishasobol:ethexe-derive-more-fmt
Draft

refactor(ethexe): replace manual fmt::Display/Debug impls with derive_more#5521
grishasobol wants to merge 1 commit into
gear-tech:masterfrom
grishasobol:ethexe-derive-more-fmt

Conversation

@grishasobol
Copy link
Copy Markdown
Member

Summary

Replaces 8 hand-written fmt::Display/fmt::Debug impls across the ethexe workspace with their derive_more equivalents. Net -20 lines and the local format strings now live next to the type they format.

Migrations

Crate Type Trait Notes
ethexe-blob-loader BlobLoaderEvent Debug Delegates to inner via #[debug("{_0:?}")]
ethexe-node-loader ValueProfile Display Lowercase variant names via per-variant #[display]
ethexe-cli RawOrFormattedValue<C> Display Forwards to inner
ethexe-malachite-core Address Display 0x{hex}
ethexe-malachite-core ValueId Display + Debug 0x{hex} / ValueId(0x{hex})
ethexe-malachite MalachiteEvent Display Per-variant #[display]
ethexe-common HashOf<T> Debug HashOf<short>({hash:?})
ethexe-common MaybeHashOf<T> Debug MaybeHashOf<short>({option_string})

Skipped (kept manual)

  • CoordinatorBoot::Debug — uses debug_struct(..).finish_non_exhaustive().
  • AlternateCollectionFmt::Debug — branches on f.alternate().
  • FormattedValue::Display, LoadRunReport::Display — non-trivial logic (trim trailing zeros, build pretty multi-line summaries).

Notes

  • The shortname<T>() helper in ethexe/common/src/hash.rs is now flagged by the dead_code lint because rustc does not trace function calls placed inside the format_args! invocations emitted by derive_more::Debug. cargo expand confirms the function is still called; the macro-generated code reads format_args!("HashOf<{0}>({1:?})", shortname::<T>(), hash). An #[allow(dead_code)] is added with a comment explaining this.
  • Adds derive_more to the dependencies of crates that did not yet use it (blob-loader, cli, node-loader, malachite-core, malachite).

Test plan

  • cargo check --workspace --all-targets is clean.
  • cargo nextest run -p ethexe-common -p ethexe-blob-loader -p ethexe-node-loader -p ethexe-cli -p ethexe-malachite-core -p ethexe-malachite — 183 passed, 1 leaky (pre-existing test_formatted_value handle leak, test result reports 1 passed; 0 failed).
  • Full CI run.

🤖 Generated with Claude Code

…_more

Replaces 8 hand-written `fmt::Display`/`fmt::Debug` impls across the ethexe
workspace with their `derive_more` equivalents:

- `ethexe/blob-loader`: `BlobLoaderEvent` Debug (delegates to inner field).
- `ethexe/node-loader`: `ValueProfile` Display (lowercase variant names).
- `ethexe/cli`: `RawOrFormattedValue<C>` Display (forwards to inner).
- `ethexe/malachite/core`: `Address` Display, `ValueId` Display + Debug
  (hex-encoded byte arrays).
- `ethexe/malachite/service`: `MalachiteEvent` Display (per-variant).
- `ethexe/common`: `HashOf<T>` and `MaybeHashOf<T>` Debug (use `shortname<T>`).

The `shortname` helper now carries `#[allow(dead_code)]` because the
`dead_code` lint does not trace function calls placed inside the
`format_args!` invocations emitted by `derive_more::Debug`.

Adds `derive_more` to the dependencies of crates that did not yet use it
(`blob-loader`, `cli`, `node-loader`, `malachite-core`, `malachite`).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant