Cpp2Rust: Automatic Translation of C++ to Safe Rust
Source: https://github.com/Cpp2Rust/cpp2rust (135⭐) Paper: https://web.ist.utl.pt/nuno.lopes/pubs/cpp2rust-pldi26.pdf — PLDI 2026
Architecture
- Parses C++ with clang AST
- Traverses AST and emits Rust code as strings
- Inserts calls to
libcc2rsruntime library for raw pointer semantics - Pretty-prints with rustfmt to a single
.rsfile
Key Design Decision
- Default model: Reference counting model produces fully safe Rust
- Alternative:
--model=unsafefor debugging/performance comparisons - Runtime library:
libcc2rswithPtr<T>type modeling C pointer semantics (null, arithmetic, aliasing) while satisfying Rust’s borrow checker through checked run-time operations
Relevance
- Automated translation between systems languages is a maturing field
- The paper was accepted at PLDI 2026 (top-tier PL conference)
- Pattern: using runtime checks to bridge semantic gaps between languages