Skip to content

Derive-crate cleanups from review#10

Merged
lthiery merged 2 commits into
mainfrom
derive-cleanups-main
Jul 7, 2026
Merged

Derive-crate cleanups from review#10
lthiery merged 2 commits into
mainfrom
derive-cleanups-main

Conversation

@lthiery

@lthiery lthiery commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Re-opened against main — the previous attempt (#8) was merged into the rust-2024 branch rather than main, so these commits never actually landed. Same content, rebased onto current main:

  • Overflow safety: the unit constructors (kb(), mib(), …) now use checked_mul and panic with a clear message instead of silently wrapping in release builds. ByteScale::pb(20_000) used to return garbage; now it panics in both debug and release (regression test included, verified in --release). In const contexts the panic becomes a compile error.
  • Derive refactor: #[derive(HumanByte)] parsed its input once per sub-derive and round-tripped everything through strings (format! on five TokenStreams, then re-parse). It now parses once and composes proc_macro2::TokenStreams directly. Generated code is identical; all tests pass unchanged.
  • Docs/typos: range_stop doc said "explicit lower bound" (it sets the upper bound); ByteSizeVistorByteSizeVisitor.
  • CI: drop the pull_request: branches: [main] filter so PRs against any base branch get CI (stacked PR Derive-crate cleanups from review #8 got none, which is how the mis-merge went unnoticed).

Not included (intentionally): the lossy human-readable serde roundtrip (1500 B"1.5 KiB"1536) — that's a wire-format behavior change worth its own decision.

lthiery added 2 commits July 7, 2026 18:44
- HumanByte derive now parses the input once and composes
  proc_macro2::TokenStreams directly instead of round-tripping every
  sub-derive through strings and re-parsing five times
- unit constructors (kb, mib, ...) use checked_mul and panic on
  overflow instead of silently wrapping in release builds; documented
  and covered by a release-mode-verified regression test
- fix range_stop doc (said lower bound, is upper bound) and the
  ByteSizeVistor -> ByteSizeVisitor typo
Stacked PRs (base = another feature branch) were getting no CI at all
because of the pull_request branches filter.
@lthiery lthiery merged commit 7e12173 into main Jul 7, 2026
1 check passed
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