Rustfmt: format macros

Created on 9 Mar 2015  路  2Comments  路  Source: rust-lang/rustfmt

This will be interesting...

a-macros fun!

Most helpful comment

The strategy here will be to get the text for the macro, replace every $foo in the body of the macro with a string of the same length, e.g., xfoo. Then re-parse it and format it and convert the xfoos back to $foos (obvs we need to check that there is no xfoo in the body before substituting).

We'll need to format the decl of the macro, and find the body, I suppose, using token trees.

All 2 comments

The strategy here will be to get the text for the macro, replace every $foo in the body of the macro with a string of the same length, e.g., xfoo. Then re-parse it and format it and convert the xfoos back to $foos (obvs we need to check that there is no xfoo in the body before substituting).

We'll need to format the decl of the macro, and find the body, I suppose, using token trees.

Google led me here. Is it worth closing this issue now, since rustfmt does have basic macro support?

Was this page helpful?
0 / 5 - 0 ratings