Is it possible to get the expansion of a single ma

2020-06-30 05:42发布

I just found How do I see the expanded macro code that's causing my compile error?. Is it possible to get the expansion of a single macro instead of the whole file?

2条回答
霸刀☆藐视天下
2楼-- · 2020-06-30 06:18

The cargo-expand command is really just a thin wrapper around cargo rustc -- -Zunstable-options --pretty=expanded, which is itself a blunt instrument. You can't target a specific macro.

However, since version 0.4, you can reduce some noise by specifying an extra path argument to expand only macros used by that module:

$ cargo expand path::to::module
查看更多
forever°为你锁心
3楼-- · 2020-06-30 06:24

"Show expanded macro" and "Show recursively expanded macro" commands were recently added to IntelliJ Rust.

A gif demo from CLion blog post:

Demo

查看更多
登录 后发表回答