Prevent rustfmt from messing with verusfmt #38
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rustfmt messes with verusfmt's formatting, and this has been the cause of idempotency issues such as #33 and #36. With this PR, we close that out (hopefully) entirely.
In short, we add a new (minimal) parser that collapses any
verus!{ ... }
intoverus!{}
before passing it to rustfmt; upon getting a result from rustfmt, we expand out thoseverus!{}
toverus!{ ... }
again, thereby preventing rustfmt from messing with anything inside the body that we have carefully set up already.This also allows us to enable the NR snapshot test, which is now stable. Fwiw, we could have fixed NR's non-idempotency if we could pass multiple macros to
rustfmt
'sskip_macro_invocations
config; however, that is blocked on an issue in rustfmt: rust-lang/rustfmt#6097; even once that is fixed, we would need to assume/check that the user is on recent-enough rustfmt (also it turns out thatskip_macro_invocations
is not stable on rustfmt), so the fix that this PR does is a much more manageable fix for us overall.Additionally, this PR also adds in vstd as a snapshot test (which could not be added before, due to same idempotency issue).
Fixes #36