Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand only macros that come from a specific crate #68

Open
dr-bonez opened this issue Sep 6, 2019 · 4 comments
Open

Expand only macros that come from a specific crate #68

dr-bonez opened this issue Sep 6, 2019 · 4 comments

Comments

@dr-bonez
Copy link

dr-bonez commented Sep 6, 2019

Would be good to be able to only expand specific macros and leave other source as is.

i.e.: cargo expand --crate="my-crate-derive"

or cargo expand --derive=MyTraitA,MyTraitB

at the very least would be good to not expand macros that come from std.

@kangalio
Copy link

kangalio commented Nov 5, 2020

This would be a game-changer, because it would allow you to use cargo-expand to "inline" utility macros like thiserror.

Right now a lot of manual effort is required to do this, because you either have to reimplement the macro functionality in plain code yourself or, if you're using cargo-expand, go through all the expanded stdlib macros (println! and family) and un-expand them.

So yeah, that would be pretty damn cool and make this tool like, at least twice more useful

@dtolnay
Copy link
Owner

dtolnay commented Sep 2, 2021

I would accept a PR to implement this.

@tqwewe
Copy link

tqwewe commented Apr 13, 2022

This would be incredible! When developing macros I have to fix up all the expanded panics, format!'s, etc.
It would be great if I could only expand a specific macro.

$ cargo expand utils::some_util --macro tokio::main

@dtolnay dtolnay changed the title feature: expand only macros that come from a specific crate Expand only macros that come from a specific crate Aug 4, 2023
@BenMcAvoy
Copy link

Is there any development on this? If not I may look into attempting to do it myself and make a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants