Is it possible to get the expansion of a single macro instead of the whole file?

天大地大妈咪最大 提交于 2019-12-09 07:21:23

问题


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?


回答1:


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



回答2:


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

A gif demo from CLion blog post:



来源:https://stackoverflow.com/questions/51917354/is-it-possible-to-get-the-expansion-of-a-single-macro-instead-of-the-whole-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!