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?
Asked
Active
Viewed 5,418 times
9
-
3Wow from +6 to -3. @Shepmaster I think people weren't happy with your editing. Just joking ;) – bertfred Sep 08 '18 at 11:02
-
5Your question was brought up on Meta, and they did not feel that the question's rating was on par with its quality. Next time, please show additional effort in your questions. – E_net4 Sep 11 '18 at 05:01
-
@E_net4 do you have a link to the meta thread? – Tim Diekmann Oct 08 '18 at 09:12
-
2@TimDiekmann https://meta.stackoverflow.com/q/373705/1233251 – E_net4 Oct 08 '18 at 09:14
2 Answers
17
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

Peter Hall
- 53,120
- 14
- 139
- 204
6
"Show expanded macro" and "Show recursively expanded macro" commands were recently added to IntelliJ Rust.
A gif demo from CLion blog post:

ozkriff
- 1,269
- 15
- 23
-
2
-
It's a part of the plugin's logic, so I guess that you can't use it outside of IntelliJ-Rust. – ozkriff Oct 08 '18 at 14:56