🤖 AI Summary
Automatically migrating C systems software to Rust faces significant challenges at the interface level, where satisfying Rust’s ownership and borrowing rules is difficult due to the lack of correct and precise translation methods. This work proposes the first constraint-solving–based approach that jointly models semantic equivalence and type correctness—including Rust’s borrow checker constraints—to establish a precise mapping between C and Rust type systems. The method generates minimal-overhead foreign function interface declarations that are directly usable by safe Rust code. Supporting modular and incremental migration, it produces state-of-the-art Rust interfaces for real-world C programs, substantially improving translation quality. However, support for certain C language features and scalability to very large codebases remains an area for future improvement.
📝 Abstract
Automatically translating system software from C to Rust is an appealing but challenging problem, as it requires whole-program reasoning to satisfy Rust's ownership and borrowing discipline. A key enabling step in whole-program translation is interface translation, which produces Rust declarations for the C program's top-level declarations (i.e., structs and function signatures), enabling modular and incremental code translation.
This paper introduces correct, precise C-to-Rust interface translation, called &inator. &inator employs a novel constraint-based formulation of semantic equivalence and type correctness including borrow-checking rules to produce a Rust interface that is correct (i.e., the interface admits a semantics-preserving implementation in safe Rust) and precise (i.e., it uses the simplest, least costly types). Our results show &inator produces correct, precise Rust interfaces for real C programs, but support for certain C features and scaling to large programs are challenges left for future work. This work advances the state of the art by being the first correct, precise approach to C-to-Rust interface translation.