Ignoring empty statements in closures.#6128
Conversation
ytmimi
left a comment
There was a problem hiding this comment.
Thanks for another PR. I think we can simplify the implementation of iter_stmts_without_empty slightly, and I'd like to expand on the test cases that you've already added.
ytmimi
left a comment
There was a problem hiding this comment.
Thanks for adding those additional test cases, and for applying the other feedback. Please take a look at my follow up comments when you have a moment.
There was a problem hiding this comment.
I think this test case is a great addition! Also wanted to note that you can totally continue to add new files as test cases, though you might find it easier to place all of these test cases into a single file.
There was a problem hiding this comment.
I don't know what I have to do)))
There was a problem hiding this comment.
I'm letting you know that instead of creating multiple test files you can add more than one test case to a single file.
for example:
fn foo() -> fn(i32) -> i32 {
|a| {
;
a
}
}
fn bar() -> fn(i32) -> i32 {
|a| {
;
a;
b
}
}
fn foobar() -> fn(i32) -> i32 {
|a| {
;
;
;;;;
a
}
}
fn baz() -> fn(i32) -> i32 {
|a| {
/*comment before empty statement */;
a
}
}44c5617 to
5d5960d
Compare
|
@rscprof Thanks again for your help on this. I've taken another look at this PR and there's another test case that I'd like to see if we can resolve before merging. Given the following input: fn foo() -> fn(i32) -> i32 {
|x| {
/*comment before empty statement */;/*comment between statements */;
x
}
}it formats as fn foo() -> fn(i32) -> i32 {
|x| {
/*comment before empty statement */ /*comment between statements */
x
}
}running rustfmt again formats as fn foo() -> fn(i32) -> i32 {
|x| {
/*comment before empty statement */
/*comment between statements */
x
}
}and running rustfmt once again stabilizes as: fn foo() -> fn(i32) -> i32 {
|x| {
/*comment before empty statement */
/*comment between statements */
x
}
} |
Solve #6116