From C to Idiomatic Rust: A Ship-of-Theseus Agentic Translation
Abstract
C underpins operating systems, embedded platforms, and network infrastructure as its abstractions map directly to machine behaviour. Its explicit memory model, predictable data representations, and minimal runtime allow compilers to generate fast, deterministic code. These properties also leave correctness and memory safety entirely to the programmer, making undefined behaviour, pointer misuse, and lifetime errors persistent sources of defects and security vulnerabilities in long-lived C codebases. Rust eliminates most failure modes through a static ownership and borrowing model that enforces memory safety and aliasing constraints at compile time. However, mature C systems cannot be translated directly: implicit layout assumptions, aliasing patterns, and undefined behaviour must be reconstructed before safe Rust can be produced. 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, a real-world DNS tunnel, the approach demonstrates that reliable C-to-Rust migration is a structured transformation workflow rather than a single translation step.
Create a lesson
Metadata
- Categories
- cs.SE, cs.OS, cs.PL
Related papers
Multi-Agent Coordinated Method-Level Refactoring of Rust Code
Shared title terminologycs.SEYijian Zheng, Yi Zhang, Juyuan Zhang et al.
Re-Testing LLM-Based C-to-Rust Translations Against Their Original C
Shared title terminologycs.SEMuhammad Hassnain
How Much Do Coding Agents Over-Edit, and Why? An Empirical Study of Unneeded Edits in Repository-Level Agent Patches
Shared title terminologycs.SEAakash Goel, Benjamin Steenhoek, Yu Hu
Evaluating More with Less: Black-Box Test Selection for AI Agents
Shared title terminologycs.SEAli Asgari, Mitchell Olsthoorn, Arie van Deursen et al.
SmartLens: Turning AI Agent Changes into Learning, Review, and Risk Signals in the IDE
Shared title terminologycs.SEVahid Etemadi, Gregorio Robles
DevEx is for Humans, AX is for Agents: Measuring Context Health in Agentic Software Work
Shared title terminologycs.SEGratiana Fu, Josh Beitler, Brian Houck