Allow showing the expanded macros of only a given module / source file

8a8a476
Opened by Boscop at 2019-01-14 07:42:45

When working with many macros, looking at the expanded macro output of the whole crate doesn't scale.

There should be an option to only show the expanded macros from a given module / source file.

E.g. in one case I have 81733 lines in the expanded macro output from cargo rustc -- -Z unstable-options --pretty=expanded...

  1. I should have reported this when https://github.com/dtolnay/cargo-expand/issues/8 was filed, but :+1: from me and :+1::+1::+1::+1::+1::+1::+1::+1::+1::+1::+1::+1: from 12 people over there.

    David Tolnay at 2017-11-19 08:52:39

  2. I implemented a workaround in cargo-expand 0.4 for now by filtering the compiler's output through Syn. For example you can run:

    expand contents of one module:

    $ cargo expand punctuated::printing
    

    expand a single item (struct, function, trait, etc):

    $ cargo expand token::FatArrow
    

    David Tolnay at 2019-01-14 07:42:45