-
Notifications
You must be signed in to change notification settings - Fork 889
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
reorder_impl_items
adds empty line between single-line macros
#5323
Comments
Thanks for the report. Confirming I can reproduce this on |
Was able to track this down to Lines 597 to 605 in a37d3ab
It feels to me like the best way to solve this would be to introduce a new option to control the line spacing of items in impl blocks. |
Nice. So maybe option then for setting if macros (or functions) and maybe all the other types should have empty line between them? Functions do get that with this also, which I think most do prefer but could be configurable as well. |
I think it would be great if we had the flexibility to independently control the spacing for all ast::AssocItemKind variants. I have some ideas for what that option might look like. I'll try to set aside some time this weekend to work on it! |
I'd like to suggest some caution here. Trying to maintain/manipulate blank lines relative to items that are getting moved around isn't something I'd be terribly keen on trying to implement nor maintain. We already have other options relative to minimum/maximum spacing that should be applicable in this context, but those have their own outstanding implementation issues and bugs. Before seriously considering another bevy of configuration options I'd really want to understand the use case(s) and associated prevalence, alongside respective gaps relative to the existing surface of configuration options. |
Also to be clear, I'm not saying "no"; just want to talk it out a bit before we invest in developing something |
@calebcartwright I hear you! I think I quickly found where we'd need to make changes to try to implement custom spacing between items and at that point the gears started turning on how we might go about it. Admittedly, I started brainstorming ideas before exploring the other spacing options that we already have so I'll be sure to take a look at them before workin on any implementation of a new feature. Taking a quick look now blank_lines_lower_bound and blank_lines_upper_bound could probably be used, but that would apply globally, and not just in the context of impl blocks. I also think if we were to implement an option it would control the spacing between similar items like a |
I worry about the potential to spiral, especially if we end up supporting both reordering/regrouping. We can always go into it thinking we'll just do one for the current ask, but it's practically inevitable that sooner or later someone will come asking for a slight variant and it gets increasingly difficult to justify one but not the other. |
We have some macros that we use inside
impl
statements that look like this:that when formatting with
reorder_impl_items=true
gets rearranged to have a new empty line between them:Which is a bit more verbose. Should/could this option skip macros inside impl statements or maybe specifically skip single-line macros? That would be nice!
Not sure how how common this pattern is but we do use it for some types. We could potentially move the macro out of the impl statement, could be a bit more standard but do quite like that this location is clear that it just adds implementation.
The text was updated successfully, but these errors were encountered: