Repository navigation
refactor(runtime): derive frame demand metadata with strum - #507
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (1)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🟢 Approval recommended
It is a mechanical, behavior-preserving refactor whose diagnostic names, ordering, variant rename, and const APIs are fully covered by existing golden/density tests that I verified remain consistent.
0 open findings
What changed in this PR
This PR refactors the DemandReason frame-demand enum in neomacs-display-runtime from a hand-rolled demand_reasons! macro (which generated the enum, ALL, COUNT, and the name match table) to a plain enum that derives its metadata via strum::EnumCount, VariantArray, and VariantNames. The goal is to reduce the custom-macro surface while preserving the existing ALL/COUNT/name APIs and the stable snake_case diagnostic vocabulary used by frame metrics.
Changes:
- Replace the
demand_reasons!macro with a normal enum using strum derives plus#[strum(serialize_all = "snake_case")], deriving diagnostic names from variant identifiers. - Rename the
WebKitvariant toWebkitso itswebkitdiagnostic name needs no per-variant override; update the two call sites. - Reimplement
COUNT,ALL, andconst fn nameas thin adapters over the derived strum traits, keeping the fixed-size-array and const-expression API intact.
| File | Description |
|---|---|
| crates/neomacs-display-runtime/src/render_thread/frame_sched.rs | Replaces the macro with a strum-derived enum and const adapters for COUNT/ALL/name. |
| crates/neomacs-display-runtime/src/render_thread/lifecycle.rs | Updates the WebKit → Webkit variant reference at the webkit-active call site. |
| crates/neomacs-display-runtime/src/render_thread/tests/frame_sched_test.rs | Updates the test assertion to the renamed Webkit variant. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Frame-demand reasons were declared through a custom macro that generated the enum, variant list, count, and diagnostic-name match. Replace it with a normal enum using
strum::EnumCount,VariantArray, andVariantNames.Derive diagnostic names with enum-level
snake_caseand preserve declaration order. Rename the internalWebKitvariant toWebkitso its existingwebkitdiagnostic spelling needs no override. Small constant adapters retainDemandReason::ALLas a fixed-size array,COUNT, and theconst fn nameAPI, including use in diagnostic constant tables. Existing enumset and enum-map derives remain in place. No dependency or lockfile changes are needed.Validation: all 46 scheduler tests pass with
cargo nextest run -p neomacs-display-runtime --lib -E 'test(render_thread::frame_sched::frame_sched_test::)'. This includes the independent golden diagnostic names, dense indices, enum-set iteration order, and all per-window counters. Rustfmt and diff checks pass. Existing unit tests remain inrender_thread/tests/frame_sched_test.rs.