rustfmt
rustfmt copied to clipboard
Remove extra unnecessary blocks
Description
It should be safe to remove unnecessarily nested blocks when there's no statements in between: {{{ <stmts> }}} => { <stmts> }.
Example
Input:
fn f() {
{{{{{ g() }}}}};
}
Expected output:
fn f() {
g();
}
Actual output:
fn f() {
{
{
{
{
{
g()
}
}
}
}
};
}
Hi, I would like to contribute to this issue, please assign me and point to where I should look for these.
@0xSaksham Thanks for your interest in working on this. You can assign yourself by commenting @rustbot claim. I'd encourage you to read the Issue claiming section of the rustc dev guide.
I imagine this option would work just like remove_nested_parens, and you can check out how remove_nested_parens is implemented by looking at rewrite_paren.
Maybe it makes sense to implement this logic in walk_block_stmts, but to be honest I haven't looked into this so you'll need to do some investigating on your own.
@rustbot claim
@vats004 Are you working on this? If you are no longer able to work on this issue, I'll try to tackle it.
Edit: It's been a month since you've claimed this, and I implemented it myself.
@rustbot release-assignment