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

  1. Parses C++ with clang AST
  2. Traverses AST and emits Rust code as strings
  3. Inserts calls to libcc2rs runtime library for raw pointer semantics
  4. Pretty-prints with rustfmt to a single .rs file

Key Design Decision

  • Default model: Reference counting model produces fully safe Rust
  • Alternative: --model=unsafe for debugging/performance comparisons
  • Runtime library: libcc2rs with Ptr<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