Skip to content

transpiler: support opt-in scalar value initialization - #48

Open
shuaimu wants to merge 1 commit into
mainfrom
codex/raft-value-init
Open

transpiler: support opt-in scalar value initialization#48
shuaimu wants to merge 1 commit into
mainfrom
codex/raft-value-init

Conversation

@shuaimu

@shuaimu shuaimu commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a fail-closed #[cfg_attr(any(), cpp_value_init)] marker for named scalar fields on ordinary Rust structs
  • emit a C++ default member initializer (field{}) only for annotated bool/integer fields, leaving unmarked fields unchanged
  • validate the exact inert marker spelling, placement, cardinality, and supported types before code generation
  • wire validation through both ordinary and pre-lowered transpilation paths

Why

Raft message structs need selected scalar fields to retain historical C++ plain-default-construction semantics while remaining valid Rust source. The inert marker gives code generation that narrow ABI/behavior hint without adding constructors or changing aggregate layout or positional initialization.

Validation

  • unit and golden coverage accepts bool and signed/unsigned integer primitive fields and rejects malformed spellings, duplicates, unsupported types, and invalid placements
  • compile-and-run coverage checks generated spelling, scalar zeroing, aggregate/standard-layout/trivially-copyable traits, field offsets, size/alignment, and positional initialization

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