Skip to content

Does rustfmt format macro calls? #5437

Discussion options

You must be logged in to vote

The short answer is: sometimes, but only in certain cases

rustfmt is a Rust code formatter which operates as a pretty-printer of the parsed AST (Abstract Syntax Tree) representation of a Rust program. rustfmt has rules defined for each type of AST node it could encounter, such as a match expression, or a function definition, and as rustfmt walks the AST of a program it emits the formatted result for each node it encounters according to the corresponding rules.

However, macros can be, and often are, used to extend the language with syntax that isn't directly valid Rust syntax, for example the html! macro provided by the yew crate. rustfmt sees these macro calls in their raw form with arg t…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by calebcartwright
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant