🤖 AI Summary
This work addresses the challenge of automating extract-function refactoring in Rust, which is hindered by its ownership system, borrowing rules, and advanced type features. Existing tools are either inefficient or lack guarantees of behavioral equivalence. To overcome these limitations, the authors present REM 2.0, a toolchain built on rust-analyzer that uniquely integrates low-latency refactoring with optional formal verification. REM 2.0 automatically adjusts lifetimes and function signatures to support complex language constructs such as async/await and generics, and can optionally invoke CHARON and AENEAS to generate Coq proofs of semantic equivalence. Leveraging a persistent daemon architecture, the system achieves millisecond-level responsiveness—reducing refactoring latency from ~1000 ms to single-digit milliseconds—demonstrates 100% compatibility across 40 real-world repositories, and successfully completes end-to-end verification in 20 case studies.
📝 Abstract
Refactoring tools are central to modern development, with extract-function refactorings used heavily in day-to-day work. For Rust, however, ownership, borrowing, and advanced type features make automated extract-function refactoring challenging. Existing tools either rely on slow compiler-based analysis, support only restricted language fragments, or provide little assurance beyond"it still compiles."This paper presents REM2.0, a new extract-function and verification toolchain for Rust. REM2.0 works atop rust-analyzer as a persistent daemon, providing low-latency refactorings with a VSCode front-end. It adds a repairer that automatically adjusts lifetimes and signatures when extraction exposes borrow-checker issues, and an optional verification pipeline connecting to CHARON and AENEAS to generate Coq equivalence proofs for a supported Rust subset. The architecture is evaluated on three benchmark suites. On the original REM artefact, REM2.0 achieves 100% compatibility while reducing latency from ~1000ms to single-digit milliseconds in the daemon. On 40 feature-focused extractions from 20 highly starred GitHub repositories, REM2.0 handles most examples involving async/await, const fn, non-local control flow, generics, and higher-ranked trait bounds. On twenty verification benchmarks, the CHARON/AENEAS pipeline constructs end-to-end equivalence proofs for cases within its current subset. Overall, results show that a rust-analyzer-based design can provide fast, feature-rich extract-function refactoring for real Rust programs, while opt-in verification delivers machine-checked behaviour preservation.