Skip to content
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

Automatic formatting for the seq! macro #71

Merged
merged 3 commits into from
May 30, 2024
Merged

Automatic formatting for the seq! macro #71

merged 3 commits into from
May 30, 2024

Conversation

jaybosamiya
Copy link
Collaborator

@jaybosamiya jaybosamiya commented May 29, 2024

Fairly straightforward implementation of the seq! macro by reusing the comma-delimited-exprs. When everything within a seq fits on a single line, it places it on single line, otherwise each element gets its own line.

CC @mmcloughlin because of #42

@jaybosamiya jaybosamiya requested a review from parno May 29, 2024 01:37
@jaybosamiya
Copy link
Collaborator Author

jaybosamiya commented May 29, 2024

Automatic merging upon approval enabled. This didn't need any snapshot updates for vstd, so should be safe to release without coordinating with Verus vstd.

@mmcloughlin
Copy link

Awesome, thank you for this!

Copy link
Contributor

@parno parno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good to me. In this bit:

 attr* ~ seq_str ~ bang_str ~ !"=" ~

why is the !"=" needed?

@jaybosamiya
Copy link
Collaborator Author

Hmm, I am not sure it is actually necessary for this spot; that sort of thing was necessary for the non-specialized macro invocations to prevent it from taking up a token tree in the case of someone did something like foo != bar (where the = would be a valid token_tree, iirc), but for the specific case of macros like calc and seq, we don't actually need that, since if the { does not show up, then it is not going to attempt a token_tree check there anyways. I'll push a commit shortly that removes that from both calc and seq

This `!"="` is necessary for general macro calls, to prevent
accidentally considering `foo != bar` as if it were a macro call going
`foo! =` and then getting confused. However, both the `calc` and `seq`
macros explicitly check for the curly braces, so don't actually need the
negative forward lookahead.
Copy link
Contributor

@parno parno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for looking into that.

@jaybosamiya jaybosamiya merged commit 53c0590 into main May 30, 2024
8 checks passed
@jaybosamiya jaybosamiya deleted the seq-macro branch May 30, 2024 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants