The Rust language’s popularity is on the rise, but many critical codebases are still in C, posing a challenge for transition. While automatically translating C to Rust seems attractive, it often involves unsafe features that negate Rust’s memory safety advantages. This study takes a different approach, exploring how to translate C to safe Rust by maintaining memory safety through Rust’s type system. The researchers introduce a type-directed translation method, a unique static analysis technique, and a compilation strategy for C’s struct types compatible with Rust. Applied to verified C codebases, the approach successfully translates applications to safe Rust, producing an impressive 80,000 line verified cryptographic library.
https://arxiv.org/abs/2412.15042