[英]How can I get similar dependency resolution to Cargo in an existing project with only rustc for code analysis?
Rust书中提到可以使用命令rustc --pretty expanded
宏来扩展宏 。 我想使用它来测试我在箱子里写的一些宏,通过使用类似命令扩展一个示例文件
rustc -Z unstable-options --pretty expanded examples/macro_test.rs
macro_test.rs
代码如下所示:
#[macro_use] extern crate macro_crate;
use macro_crate::macros::*;
macro_foo! { foo }
fn main() {}
但是,这会导致错误0463,这就是rustc
的箱子环境一无所知:
error[E0463]: can't find crate for `macro_crate`
--> examples/macro_test.rs:1:1
|
1 | extern crate macro_test;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
推荐使用这种方法的方法是什么? 据我所知, cargo
帮助没有任何直接关系。
Cargo有一个rustc
子命令,用于调用带有附加参数的rustc
。
$ cargo rustc --example macro_test -- -Z unstable-options --pretty expanded
您还可以在--
之前添加--verbose
以使Cargo打印完整的rustc
命令行(以及其他内容)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.