Description
The libc crate has some macros, called s!
, f!
, etc. which take a series of items:
f! {
fn foo();
fn bar();
// ...
}
I know that formatting macros is very tricky, and that we probably cannot do that by default.
Instead, would it be possible to specify, e.g., in the rustfmt.toml
, a list of macros for which rustfmt
should try to format the contents as if the contents were a sequence of items ?
E.g. for the case above, rustfmt
could format the f! { ... }
the contents of ...
as if they were items, adding 4 space indentation inside the block.
I think approaches to macros in which users opt-into formatting them, and somehow conveying what the content of the macro is, might be a more viable way forward with respect to macro formatting than trying to do things automatically.
I don't know how to call this, but I could add the following to libc
's rustfmt.toml
:
format-macro-content-as-items = ["f", "s"]
I think I could use this in other crates that also make heavy use of macros, like packed-simd.