Don't insert semicolons inside of a macro_rules! arm body by Aaron1011 · Pull Request #4507 · rust-lang/rustfmt (original) (raw)

I was initially surprised by the updates to OperationSetting though see now why that was done. I'd forgotten how... fun the macro def formatting code is 😄

I feel like we should have a less painful way to track/set some visitor context when formatting macros, but that'd almost certainly require some major refactoring that we don't need to attempt to tackle here.

I'm 👍 with the objective given the likely upstream changes as well as the general approach, although I do want to see this tweaked a bit to keep things encapsulated internally within the rustfmt lib vs. exposing the macro def context through the public API (we do actually have some folks using rustfmt as a lib). This should avoid leaking any internals, and also give us flexibility to potentially refactor down the road without introducing breaking changes to the interface.

Perhaps some additional internal functions (format_input_inner and friends) could be updated to accept the new param and then utils::format_snippet could just directly use format_input_inner instead of the public-facing function.