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

add better syntax for external_fn_specification #1368

Merged
merged 12 commits into from
Jan 15, 2025
Merged

Conversation

tjhance
Copy link
Collaborator

@tjhance tjhance commented Dec 19, 2024

external_fn_specification is ugly and hard to read. This adds better syntax

examples:

pub assume_specification<T> [core::mem::swap::<T>] (a: &mut T, b: &mut T)
     ensures
         *a == *old(b),
         *b == *old(a),

For trait methods:

pub assume_specification [<bool as Clone>::clone](b: &bool) -> (res: bool)
    returns b;

The brackets make it easier to parse.

@tjhance
Copy link
Collaborator Author

tjhance commented Dec 19, 2024

if this syntax seems fine, i will port all the instances in vstd/std_specs and change all the error msgs and update docs etc.

@jaybosamiya-ms
Copy link
Contributor

I like the new syntax. Let me know if you need help with adding it to verusfmt.

@tjhance
Copy link
Collaborator Author

tjhance commented Jan 10, 2025

@jaybosamiya-ms Indeed, if you add this to verusfmt, it would be a big help.

@tjhance tjhance force-pushed the external-fn-good-syntax branch from e955213 to ea2bd82 Compare January 11, 2025 00:10
jaybosamiya-ms added a commit to verus-lang/verusfmt that referenced this pull request Jan 12, 2025
This PR adds support for the upcoming `assume_specification`
(verus-lang/verus#1368) syntax in Verus.
@parno
Copy link
Collaborator

parno commented Jan 14, 2025

Thanks for adding the cleaner syntax and for adding documentation! I notice that the new documentation lives under the "Reference" section at the end. Could we add at least a small pointer to it in the "Tutorial: Verification and Rust" section, possibly either as a top-level (short) chapter, or as a page under "Understanding the guarantees of a verified program"? The "Verification and Rust" section seems like the most likely spot for someone to look for this functionality, and I'm not sure they would immediately think to look under "assume_specification" in the Reference.

jaybosamiya-ms added a commit to verus-lang/verusfmt that referenced this pull request Jan 14, 2025
This PR adds support for the upcoming `assume_specification` (verus-lang/verus#1368) syntax in Verus.
@jaybosamiya-ms
Copy link
Contributor

Latest release of verusfmt (v0.5.1) contains support for assume_specification; it should automatically be picked up by the CI upon your next push to this PR.

@tjhance
Copy link
Collaborator Author

tjhance commented Jan 15, 2025

Tyvm!

Bryan: I will add a bit more introductory documentation like you suggest.

@tjhance tjhance force-pushed the external-fn-good-syntax branch from 2be41dc to 445004c Compare January 15, 2025 17:42
@tjhance tjhance merged commit f702dc7 into main Jan 15, 2025
11 checks passed
@tjhance tjhance deleted the external-fn-good-syntax branch January 15, 2025 18:03
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.

4 participants