最近学习rust,看到宏展开命令
#单独文件
rustc -Z unstable-options --pretty=expanded main.rs
#cargo管理
cargo rustc -- -Z unstable-options --pretty=expanded
于是在我的hello项目中测试了一下,这个演示项目使用cargo创建,里面既有lib又有bin。
% cargo rustc -- -Z unstable-options --pretty=expanded
但是出现了报错,可能是由于软件版本的变更,导致书中的命令不能直接运行,也可能是书中写的是简化示意。
error: extra arguments to `rustc` can only be passed to one target, consider filtering
the package by passing, e.g., `--lib` or `--bin NAME` to specify a single target
根据提示修改
% cargo rustc -- --bin hello -Z unstable-options --pretty=expanded
依然报相同的错误,经过测试发现用下面的方法可以通过。
% cargo rustc --bin hello -- -Z unstable-options --pretty=expanded
这两种写法有什么区别呢,一条命令后面加另一条命令的时候,如果都带有参数,当把前面的命令的参数放到后面的命令的后面的时候就会产生歧义,这个参数到底是谁的,<