-
Notifications
You must be signed in to change notification settings - Fork 926
Configuration option to preserve blank lines at beginning of block #2868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We're unlikely to do this, tbh. In the complex signature case, there is always either a line with just |
Thanks for keeping this ticket open despite its inactivity. I understand your concern for having configuration options pull their weight. Perhaps what I want doesn't require a new option type but instead could be expressed as an alternative brace style? I've distilled the “blank line” feature to the specific case that bugs me, as shown in the example below. In this example, the second function is easier on my eyes because the signature is more clearly separated from the body. I can't imagine I'm alone on this. Yet the first function is what impl MyType {
fn normal_len_fn_name_1(
&mut self,
param1: SomeOtherType,
param2: SomeOtherType,
) -> Result<i32, Error> {
let a = param1.blah();
let b = param2.bleh();
let c = param2.bluh();
return a + b + c;
}
fn normal_len_fn_name_2(
&mut self,
param1: SomeOtherType,
param2: SomeOtherType)
-> Result<i32, Error>
{
let a = param1.blah();
let b = param2.bleh();
let c = param2.bluh();
return a + b + c;
}
} Is it feasible to add or extend a configuration option to make |
I don't know where to 'request' that so I'll just add a comment here. I don't expect one comment to change anything really, but at least I can pretend it's counted. :) (I was slightly disappointed to not find this as a feature, despite indication to make it a configuration option in the original RFC: rust-lang/style-team#57 (comment) - I know priorities change and rustfmt has been actively aiming for "less options") My workaround for now is to enable Edit: I guess the option was implemented as stated in that RFC discussion, but then later culled as unused. |
I've been running into this recently and it's been infuriating trying to find a way to configure it to leave blank lines at the start of a block. This is something I'd consider to be a vital configuration option, especially looking at some of the other options that are possible. If there's any way this feature can be brought back I'd really appreciate it! |
@topecongiro @calebcartwright I am interested in taking a look at this if that's good |
That'd be great @ayazhafiz! |
Adds the option for - Functions - Control flow blocks - Expression statements (i.e. `let x = { ... };`) - Traits - Trait Impls - Mods - Foreign Mods If I am missing a kind of item, let me know :) Closes rust-lang#2868
Adds the option for - Functions - Control flow blocks - Expression statements (i.e. `let x = { ... };`) - Traits - Trait Impls - Mods - Foreign Mods If I am missing a kind of item, let me know :) Closes rust-lang#2868
Adds the option for - Functions - Control flow blocks - Expression statements (i.e. `let x = { ... };`) - Traits - Trait Impls - Mods - Foreign Mods If I am missing a kind of item, let me know :) Closes rust-lang#2868
* Configuration option to preserve blank lines at start of block Adds the option for - Functions - Control flow blocks - Expression statements (i.e. `let x = { ... };`) - Traits - Trait Impls - Mods - Foreign Mods If I am missing a kind of item, let me know :) Closes #2868 * fixup! Configuration option to preserve blank lines at start of block * Simplify `advance_to_first_block_item` * fixup! Simplify `advance_to_first_block_item`
Cherry-picked from ayazhafiz, branch i/2868. That commit was originally implemented on the 2.0 branch, while this commit adds it to stable. Original commit message: > Adds the option for > > - Functions > - Control flow blocks > - Expression statements (i.e. `let x = { ... };`) > - Traits > - Trait Impls > - Mods > - Foreign Mods > > If I am missing a kind of item, let me know :) > > Closes rust-lang#2868
…lang#4303) * Configuration option to preserve blank lines at start of block Adds the option for - Functions - Control flow blocks - Expression statements (i.e. `let x = { ... };`) - Traits - Trait Impls - Mods - Foreign Mods If I am missing a kind of item, let me know :) Closes rust-lang#2868 * fixup! Configuration option to preserve blank lines at start of block * Simplify `advance_to_first_block_item` * fixup! Simplify `advance_to_first_block_item`
It would be nice if
rustfmt
had a configuration setting for preserving blank lines at the beginning of blocks.For example, it would be nice if
rustfmt
converted this program……into the following program:
This preservation of space is especially important when the function signature spans several lines, as sometimes it's nice to have a visual break between a complex signature and the body of code.
There once was a configuration option called
remove_blank_lines_at_start_or_end_of_block
that did this, but it was removed as part of #1974 for reasons unapparent.The text was updated successfully, but these errors were encountered: