-
Notifications
You must be signed in to change notification settings - Fork 5
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
Handle trailing newlines for broadcast use
s
#55
Conversation
a1d084d
to
e6001cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me. Should we apply this to other item
s (e.g., global
)?
Good question. With this PR as a blueprint, adding such code to other similar things should be fairly straightforward, but I think we should refrain from adding for such situations until we see actual code that would benefit from the additional newlines. |
Thank you for working on this. One concern: I don't think rustfmt makes changes to add/remove empty lines in a block (as those tend to be introduced as a way to logically group/separate chunks of code by the developer), I'm a bit uneasy about departing from that general principle. |
Given verusfmt's design, we haven't found a clean enough way to maintain empty lines in blocks (even before this I can see pros and cons with rustfmt's principle regarding this; and personally I do think we should preserve empty lines in a block; however, until we find a good way to handle this (PRs welcome!), the current approach of opinionated decisions on separations is the best we've got. Fwiw, as a workaround for logically separate chunks, an empty comment line (just a |
Ah! I suspected this might be the case but didn't know about the attempts you've already made. Thanks for the write-up on the challenges and trade-off. This choice makes sense to me, then. Thanks! |
Adds an extra trailing newline for

broadcast use
groups, exemplified by this diff:Essentially, this PR handles the situation brought up by @utaal-b in #53. To lead to good output, this required handling a few special cases:
broadcast use
items in the same fnbroadcast use
itemsI've handled each of these cases to produce good output. Additionally, the snapshot test in this is is an expanded version of what @utaal-b proposed in #53.
NOTE: This PR causes an update to the vstd snapshot. This is intentional (due to style change), but will require coordination on https://github.com/verus-lang/verus when the new version of verusfmt is released. This should not block merging this PR, but yeah, from a release standpoint, will need some coordination to prevent CI failures. I'll open a PR there soon (EDIT: verus-lang/verus#1062)