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

Handle keyword-prefixed identifiers #8

Merged
merged 2 commits into from
Nov 10, 2023
Merged

Handle keyword-prefixed identifiers #8

merged 2 commits into from
Nov 10, 2023

Conversation

jaybosamiya
Copy link
Collaborator

As has been noticed before, things like as would end up causing something like assert to be parsed as as sert, and thus needed explicit workarounds like f7c22d7 (for as, is and has), or 4a9d96c (for box). #6 also is an issue of this kind (for mut). Basically, we were fixing this issue as we hit it each time, in an ad-hoc way at the use site of the specific problematic prefix.

This PR fixes it once and for all, by making all the strings make sure that they aren't a prefix of a longer string (by using a negative lookahead), that way the use-sites don't need to worry about these strings. Thus, this PR also cleans up the previous workarounds that were added in the past.

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.

Addressing this issue systematically makes sense. Looks good to me.

@jaybosamiya jaybosamiya merged commit 223251c into main Nov 10, 2023
2 checks passed
@jaybosamiya jaybosamiya deleted the keyword-matches branch November 10, 2023 15:43
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.

verusfmt doesn't handle borrows of identifiers that start with the characters mut
2 participants