rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

Handling fn empty where and comments after return type

Open davidBar-On opened this issue 3 years ago • 4 comments
trafficstars

Proposed fix for issue #5407. Although the original issue is about fn empty where clause indentation, the issue is actually about handling of comments after fn return type. This is because with current code the empty where was handled as a post return type comment.

In addition, there are related issues with handling comments for fn empty where clause without return type. Therefore the fix handles the cases of fn return type without where clause, empty where clause without return type, and return type with empty where clause.

The proposed fix seem to also resolve issue #4649.

Note that the fix is not related to issues with traits empty where clause, such as #4672.

davidBar-On avatar Jun 28 '22 07:06 davidBar-On

Thanks for your work on this! I Also appreciate you linking some relevant issues. I'm planning to get an initial review done in the next few days

ytmimi avatar Jun 28 '22 14:06 ytmimi

The proposed fix seem to also resolve issue https://github.com/rust-lang/rustfmt/issues/4649.

Could we add test cases for the linked issue if these changes help to resolve what's going on there

ytmimi avatar Jul 18 '22 01:07 ytmimi

The proposed fix seem to also resolve issue https://github.com/rust-lang/rustfmt/issues/4649.

Could we add test cases for the linked issue if these changes help to resolve what's going on there

Added test cases for the original case of #4649 with empty where.

The other reported case in #4649 with non-empty where is a different issue and is probably the same issue as reported in #4672.

davidBar-On avatar Jul 18 '22 07:07 davidBar-On

Added test cases for the https://github.com/rust-lang/rustfmt/issues/4649#issue-787737841 of https://github.com/rust-lang/rustfmt/issues/4649 with empty where.

The https://github.com/rust-lang/rustfmt/issues/4649#issuecomment-952310029 in https://github.com/rust-lang/rustfmt/issues/4649 with non-empty where is a different issue and is probably the same issue as reported in https://github.com/rust-lang/rustfmt/issues/4672.

Thank you for looking into this!

ytmimi avatar Jul 18 '22 12:07 ytmimi