Rustfmt skips macro arguments?

It is not fairly straightforward: it requires full early name resolution + macro expansion. And for the argument that it's zero-cost, it will either make people not use this feature or this "zero-cost" will have no meaning.

1 Like

Perhaps there is a way to explicitly mark a region of source code for formatting, for example, with a special comment? Something in the tune of:

tokio::select! (
        _ = futures::future::ready(true) => {
            // rustfmt: format
            foo("first very very long argument", "second very very long argument")
        }
    )

This issue affects many macros that take large tts of Rust code as arguments. Kinda needs to get resolved.

We can do better by using an attribute:

tokio::select! (
        _ = futures::future::ready(true) => {
            #[rustfmt::macro(rules = "/path/to/DSL/formatting/rules")]
            foo("first very very long argument", "second very very long argument")
        }
    )

But yeah even then it's still an open question how the definitions will be resolved and applied at that stage of the compilation process.