cargo-expand icon indicating copy to clipboard operation
cargo-expand copied to clipboard

Flag to control how deeply macros are expanded

Open dtolnay opened this issue 8 years ago • 4 comments

For example, avoid expanding try! and other macros inside the output of proc macros.

cc @djc

dtolnay avatar Feb 14 '17 16:02 dtolnay

I'd like to request this to be an arbitrary level of macro expansion. I am particularly interested in 0.

For cargo-crev I had an idea that cargo-expand could be used for a one-file view of the source code for the purpose of quick code review. I'm mostly interested in mod file conversion to mod { ... }

dpc avatar Dec 27 '18 06:12 dpc

I posted a relevant request for implementation for 0 levels: https://github.com/dtolnay/request-for-implementation/issues/6.

dtolnay avatar Jan 22 '19 17:01 dtolnay

I was thinking about this after seeing another question on the rust users forum about order of expansion, obviously this would be slightly different but I wonder if while implementing this feature one could also only expand x number of macros in order. This seems possibly helpful for people writing proc-macro's to see how they interact? If the original issue is something you want I'd take a look at it.

DevinR528 avatar Nov 04 '19 21:11 DevinR528

This seems possibly helpful for people writing proc-macro's to see how they interact? If the original issue is something you want I'd take a look at it.

I'm debugging a proc macro right now which generates a declarative macro invocation. Something's wrong about the generated declarative macro invocation, but it's hard to investigate because the invocation is expanded immediately.

This would certainly be a useful feature to have, at least for debugging proc macros

Although this need could also be solved with #68, by setting the expanded crate to the proc macro crate

kangalio avatar Apr 01 '21 08:04 kangalio