The Rust programming language, with its safety guarantees, has established itself as a viable choice for low-level systems programming language over the traditional, unsafe alternatives like C/C++. These guarantees come from a strong ownership-based type system, as well as primitive support for features like closures, pattern matching, etc., that make the code more concise and amenable to reasoning. These unique Rust features also pose a steep learning curve for programmers. This paper presents a tool called RustAssistant that leverages the emergent capabilities of Large Language Models (LLMs) to automatically suggest fixes for Rust compilation errors. RustAssistant uses a careful combination of prompting techniques as well as iteration with an LLM to deliver high accuracy of fixes. RustAssistant is able to achieve an impressive peak accuracy of roughly 74% on real-world compilation errors in popular open-source Rust repositories. We plan to release our dataset of Rust compilation errors to enable further research.
翻译:Rust编程语言凭借其安全保证,已成为传统不安全的低级系统编程语言(如C/C++)的可行替代方案。这些保证源于其基于所有权的强类型系统,以及对闭包、模式匹配等特性的原生支持,使代码更加简洁且易于推理。然而,Rust的这些独特特性也给程序员带来了陡峭的学习曲线。本文提出了一种名为RustAssistant的工具,该工具利用大型语言模型(LLM)的新兴能力,自动为Rust编译错误提供修复建议。RustAssistant通过精心组合提示技术以及与LLM的迭代交互,实现了高精度的修复。在流行的开源Rust仓库中,RustAssistant在真实编译错误上的峰值准确率达到了约74%。我们计划发布Rust编译错误数据集,以促进进一步的研究。