1 个不稳定版本
使用旧的 Rust 2015
0.1.0 | 2015年5月8日 |
---|
#1937 在 开发工具
4KB
98 行
犯错误了!
所以我有点冲动地将这个工具添加到 crates.io,没有太多考虑添加更多功能,所以如果你有一个想要命名为 ast-debug 的项目,并认为这会很棒,请告诉我,我们将设法让你的项目替换我的。
介绍
此编译器插件接受一个函数,并在其顶部添加一个 println!,其中包含当函数通过 Rust 解析器时 AST 的字符串。
示例!
#![feature(plugin)]
#[plugin] extern crate ast_debug;
ast!(fn foo() {
println!("Hello world!");
});
变为
fn foo() {
println!(" /* A lot of somewhat pretty printed AST info ends up here! */ ");
println!("Hello world!");
}
当前问题
编译器插件目前是一个不稳定特性,因此你需要 Rust 的夜间版本才能使用它们。当前的代码最终也会移除一些函数数据,即 ABI、不安全和泛型。这些问题最终可能得到解决!