What is C2Rust?
C2Rust helps you migrate C99-compliant code to Rust. It provides:
- a C to Rust translator
- a Rust code refactoring tool
- tools to cross-check execution of the C code against the new Rust code
The translator (or transpiler), produces unsafe Rust code that closely mirrors the input C code. The primary goal of the translator is to produce code that is functionally identical to the input C code. Generating safe or idomatic Rust is not a goal for the translator. Rather, we think the best approach is to gradually rewrite the translated Rust code using dedicated refactoring tools. To this end, we are building a refactoring tool that rewrites unsafe auto-translated Rust into safer idioms.
Some refactoring will have to be done by hand which may introduce errors. We provide plugins for
rustc so you can compile and run two binaries and check that they behave identically (at the level of function calls). For details on cross-checking see the cross-checks directory and the cross checking tutorial.
Here's the big picture:
To learn more, check out our RustConf'18 talk on YouTube and try the C2Rust translator online at www.c2rust.com.