# ENCRUST: Encapsulated Substitution and Agentic Refinement on a Live Scaffold for Safe C-to-Rust Translation

arXiv: https://arxiv.org/abs/2604.04527 · HTML: https://mlsanity.com/paper/2604.04527/

## Key facts

- Cited by 2 papers in the map (data through 14 Oct 2026).
- Builds on 12 of its 30 references that are in the map.
- First posted on arXiv 6 Apr 2026.

## Builds on (most cited first, 12 of 12)

- [Towards Translating Real-World Code with LLMs: A Study of Translating to Rust](https://mlsanity.com/paper/2405.11514/) (2024)
- [VERT: Verified Equivalent Rust Transpilation with Large Language Models as Few-Shot Learners](https://mlsanity.com/paper/2404.18852/) (2024)
- [EvoC2Rust: A Skeleton-guided Framework for Project-Level C-to-Rust Translation](https://mlsanity.com/paper/2508.04295/) (2025)
- [C2SaferRust: Transforming C Projects into Safer Rust with NeuroSymbolic Techniques](https://mlsanity.com/paper/2501.14257/) (2025)
- [Syzygy: Dual Code-Test C to (safe) Rust Translation using LLMs and Dynamic Analysis](https://mlsanity.com/paper/2412.14234/) (2024)
- [Ownership guided C to Rust translation](https://mlsanity.com/paper/2303.10515/) (2023)
- [RustMap: Towards Project-Scale C-to-Rust Migration via Program Analysis and LLM](https://mlsanity.com/paper/2503.17741/) (2025)
- [Integrating Rules and Semantics for LLM-Based C-to-Rust Translation](https://mlsanity.com/paper/2508.06926/) (2025)
- [Translating Large-Scale C Repositories to Idiomatic Rust](https://mlsanity.com/paper/2511.20617/) (2025)
- [SmartC2Rust: Iterative, Feedback-Driven C-to-Rust Translation via Large Language Models for Safety and Equivalence](https://mlsanity.com/paper/2409.10506/) (2024)
- [LLMigrate: Transforming "Lazy" Large Language Models into Efficient Source Code Migrators](https://mlsanity.com/paper/2503.23791/) (2025)
- [Intel MPX Explained: An Empirical Study of Intel MPX and Software-based Bounds Checking Approaches](https://mlsanity.com/paper/1702.00719/) (2017)

## Built on by (most cited first, 2 of 2)

- [Documentation-Guided Agentic Codebase Migration from C to Rust](https://mlsanity.com/paper/2605.14634/) (2026)
- [Translator vs. Challenger: Adversarial Agentic Learning for C-to-Rust Translation](https://mlsanity.com/paper/2609.15381/) (2026)

## Abstract (arXiv)

We present Encapsulated Substitution and Agentic Refinement on a Live Scaffold for Safe C-to-Rust Translation, a two-phase pipeline for translating real-world C projects to safe Rust. Existing approaches either produce unsafe output without memory-safety guarantees or translate functions in isolation, failing to detect cross-unit type mismatches or handle unsafe constructs requiring whole-program reasoning. Furthermore, function-level LLM pipelines require coordinated caller updates when type signatures change, while project-scale systems often fail to produce compilable output under real-world dependency complexity. Encrust addresses these limitations by decoupling boundary adaptation from function logic via an Application Binary Interface (ABI)-preserving wrapper pattern and validating each intermediate state against the integrated codebase. Phase 1 (Encapsulated Substitution) translates each function using an ABI-preserving wrapper that splits it into two components: a caller-transparent shim retaining the original raw-pointer signature, and a safe inner function targeted by the LLM with a clean, scope-limited prompt. This enables independent per-function type changes with automatic rollback on failure, without coordinated caller updates. A deterministic, type-directed wrapper elimination pass then removes wrappers after successful translation. Phase 2 (Agentic Refinement) resolves unsafe constructs beyond per-function scope, including static mut globals, skipped wrapper pairs, and failed translations, using an LLM agent operating on the whole codebase under a baseline-aware verification gate. We evaluate Encrust on 7 GNU Coreutils programs and 8 libraries from the Laertes benchmark, showing substantial unsafe-construct reduction across all 15 programs while maintaining full test-vector correctness.
