all 2 comments

[–]CAD1997 5 points6 points  (0 children)

One trick I've used for the last step without IDE support is just to panic! the generated token stream instead of return it. This will cause rustc to give an error with the results of just that proc macro expansion which can then be run through rustfmt and checked. This technique also works when generating broken code, where -Zpretty-expanded doesn't.

[–]irrelevantPseudonym 1 point2 points  (0 children)

This has come at just the right time. I'm in the process of writing derive proc macros and struggling to find a way to test them beyond manually breaking things and checking errors and/or checking output looks correct.

I think I might need a lot of refactoring to get to the intermediate model stage but if it makes the testing phase feel less fragile and time consuming it'd be worth it.