rustfmt
rustfmt copied to clipboard
Keep the comment after where clause that has no predicate (#4649)
The pull request aims at solving #4649, and formats the comment that occurs before the where-clause; two cases are handled by the modified code:
whereexists but does not have any predicate: For this scenario, it would be great to have people's input on
- the indent of the comment
- If we always put the comment in a new line (the current behavior is to always add
\nright afterwhere). Several test cases inissue_4649.rswould fail.
wheredoes not exist. In this scenario, rustfmt behaves the same as before.
Any suggestion is appreciated!
Now that I looked through other place where where is formatted, perhaps we should create a function format_comment_after_where to be used?
If we use the approach in this PR to format where clause in all scenarios, I think #4672 can also be resolved.
Looks like this now has a lot of CI/test failures. Could you please take a look when you get a chance?
The idempotent tests were ran against two different config; the current failure output looks like theis:
Mismatch at tests/source/issue-4649.rs:7:
fn bar2(&self, a: T)
where
- /* Self: Bar */;
+ /* Self: Bar */;
}
Mismatch at tests/source/issue-4001.rs:1:
fn unit() -> ()
where
- /* comment */ {
+ /* comment */ {
()
}
But if I change the target snippet to match the outcome above, the failure output became:
Mismatch at tests/source/issue-4649.rs:7:
fn bar2(&self, a: T)
where
- /* Self: Bar */;
+ /* Self: Bar */;
}
Mismatch at tests/target/issue-4649.rs:7:
fn bar2(&self, a: T)
where
- /* Self: Bar */;
+ /* Self: Bar */;
}
Mismatch at tests/source/issue-4001.rs:1:
fn unit() -> ()
where
- /* comment */ {
+ /* comment */ {
()
}
Mismatch at tests/target/issue-4001.rs:1:
fn unit() -> ()
where
- /* comment */ {
+ /* comment */ {
()
}
What are some way to circumvent this?