From C to Idiomatic Rust: A Ship-of-Theseus Agentic Translation
- Source
- arxiv.org
- Author
- Vasily A. Sartakov
- Date

Context
Moving an established C program to Rust involves preserving behavior while changing how the code is organized. This case study describes a staged approach: first produce a Rust baseline intended to preserve the C program's behavior, then use an to rewrite it incrementally into conventional Rust. Each step is checked by compilation and behavioral tests. The authors applied the method to iodine, a codebase of roughly 12,500 source lines. The useful contribution is the separation of translation from restructuring, with checks between changes. Evidence comes from one migration, and those checks do not amount to a formal proof of equivalence.
- Mature C cannot be handed straight to a translator because the source hides its own contract. Implicit memory layout assumptions, aliasing patterns, and undefined behavior all have to be reconstructed before any safe Rust can be produced.
- Rust is worth the trouble because ownership and borrowing turn the guarantees C leaves entirely to the programmer, memory safety and aliasing discipline, into things the compiler checks before the program runs.
- Generating a deliberately non-idiomatic Rust baseline first separates two failure modes: 'does it still behave like the C' and 'is this good Rust'. Debugging one at a time is what makes the process reliable at 12.5k lines.
- AI agent — An AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.
“This paper presents a migration methodology that first generates a semantics-preserving, non-idiomatic Rust baseline and then incrementally rewrites it into idiomatic Rust using agentic AI, validating each step through compilation and behavioural testing.”
“Applied to iodine (12.5k SLOC), the approach demonstrates that reliable C-to-Rust migration is a structured transformation workflow rather than a single translation step.”
Checking sign-in…
Loading comments…


