Open Veetaha opened 2 months ago
Maybe we need to extend inline_attribute_width
(https://github.com/rust-lang/rustfmt/issues/3343) to also apply to function parameters?
Maybe we need to extend inline_attribute_width (https://github.com/rust-lang/rustfmt/issues/3343) to also apply to function parameters?
It definitely makes sense, but could it just be the default? I mean that the attribute isn't placed on the same line in function arguments?
rustfmt can't change default formatting because of it's stability guarantee. Breaking changes can only be made if they're gated.
I see, well, at least the default can be changed across editions, but having a config override in the meantime is reasonable
Any change to leverage inline_attribute_width
would need to be gated since the default value for the option is 0
, which would force the wrapping behavior that you're looking for.
Context
Hi, I'm the author of the crate
bon
. It exposes a proc macro that generates a builder for a function. Every function parameter can be configured with additional#[builder(...)]
options.Problem
For example, this function declares 4 parameters, two of which are optional (they have default values). As for me, the way
rustfmt
formatted this code doesn't look nice:The attribute on the function's parameter was formatted on the same line with the parameter itself, even though the signature of the function already takes up multiple lines. It is harder to read the signature this way because names of function parameters aren't aligned
I'd expect the following formatting for this example of code instead: