我遇到了一个涉及宏的编译错误:
<mdo macros>:6:19: 6:50 error: cannot move out of captured outer variable in an `FnMut` closure
<mdo macros>:6 bind ( $ e , move | $ p | mdo ! { $ ( $ t ) * } ) ) ; (
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<mdo macros>:1:1: 14:36 note: in expansion of mdo!
<mdo macros>:6:27: 6:50 note: expansion site
<mdo macros>:1:1: 14:36 note: in expansion of mdo!
<mdo macros>:6:27: 6:50 note: expansion site
<mdo macros>:1:1: 14:36 note: in expansion of mdo!
src/parser.rs:30:42: 37:11 note: expansion site
error: aborting due to previous error
不幸的是,该宏是递归的,因此很难弄清楚编译器在抱怨什么,而且似乎行号是针对扩展宏而不是我的代码。
我如何查看扩展的宏?是否有一个标志可以传递给rustc(或者更好的是cargo),以便将其转储出来?
(这个宏来自rust-mdo,但我认为这并不重要。)
rustc -Zunpretty=expanded some.rs
。有关更多详细信息,请参见Enselic的答案。 - at54321