rustc 不提供任何命令帮你自动添加 use, 只会给出这样一个帮助信息
help: consider importing this function
|
1 + use crate::openbsd_compat::bsd_closefrom::closefrom;
|
我在使用 c2rust 的过程中,需要手工添加大量的 use, 所以必须要一个自动化的方法
主要借鉴了 https://github.com/m-ou-se/auto-import
不过她这个库是侵入式的,需要添加一个 crate
而我只需要 cargo auto-import 就可以了
如何工作
首先执行一遍 cargo build --message-format=json
然后从其中找出 use xxx
的帮助信息
写入对应的源文件里
Ext Link: https://github.com/lengyijun/cargo-auto-import
1
共 1 条评论, 1 页
评论区
写评论好奇,rust-analyzer里的code-action里有这个功能吧?op做过对比嘛?