C2RustXW: Program-Structure-Aware C-to-Rust Translation via Program Analysis and LLM
Yanyan Yan, Yang Feng, Jiangshan Liu, Di Liu, Zixi Liu, Hao Teng, Baowen Xu

TL;DR
C2RustXW is a novel program-structure-aware C-to-Rust translation method that combines program analysis with LLMs to produce syntactically correct, safe, and maintainable Rust code, significantly improving over existing rule-based tools.
Contribution
It introduces a multi-level program structure extraction and a multi-stage repair pipeline that integrates rule-based and LLM-based techniques for high-quality C-to-Rust translation.
Findings
Achieves 100% syntactic correctness on CodeNet and 97.78% on GitHub.
Reduces code size by up to 43.70% and unsafe usage to 5.75%.
Attains an average semantic correctness of 78.87% at the project level.
Abstract
The growing adoption of Rust for its memory safety and performance has increased the demand for effective migration of legacy C codebases. However, existing rule-based translators (e.g., \ctorust) often generate verbose, non-idiomatic code that preserves unsafe C semantics, limiting readability, maintainability, and practical adoption. Moreover, manual post-processing of such outputs is labor-intensive and rarely yields high-quality Rust code, posing a significant barrier to large-scale migration. To address these limitations, we present \tool, a program-structure-aware C-to-Rust translation approach that integrates program analysis with Large Language Models (LLMs). \tool extracts the multi-level program structure, including global symbols, function dependencies, and control- and data-flow information, and encodes these as structured textual representations injected into LLM prompts to…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
