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

Generate contracts of dependencies as assertions #3802

Merged
merged 19 commits into from
Jan 9, 2025

Conversation

carolynzech
Copy link
Contributor

@carolynzech carolynzech commented Dec 30, 2024

Add an unstable option -Zcontracts-as-assertions that generates contract clauses as assertions. This works by adding a new contract mode that outputs the original body of the function with its contract clauses asserted. During the FunctionWithContractPass, if this option was passed, we use this closure instead of the original body of the function.

I'm omitting a description of why this is useful from the PR description--there's one in the module documentation, and I want that to be a self-contained explanation (i.e., if something is unclear, I want to fix it there).

(Also did a minor bit of cleanup, renaming ClosureType to ContractMode and moving split_for_remembers to the shared module since it has contract-specific logic.)

Resolves #3326

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@github-actions github-actions bot added the Z-BenchCI Tag a PR to run benchmark CI label Dec 30, 2024
@carolynzech carolynzech marked this pull request as ready for review January 2, 2025 17:58
@carolynzech carolynzech requested a review from a team as a code owner January 2, 2025 17:58
Copy link
Contributor

@zhassan-aws zhassan-aws left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

Only a few comments.

kani-compiler/src/args.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@zhassan-aws zhassan-aws left a comment

Choose a reason for hiding this comment

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

Thanks!

@carolynzech carolynzech enabled auto-merge January 8, 2025 21:39
@carolynzech carolynzech changed the title Add an option to generate contracts as assertions Generate contracts of dependencies as assertions Jan 9, 2025
@carolynzech carolynzech added this pull request to the merge queue Jan 9, 2025
Merged via the queue into model-checking:main with commit addc590 Jan 9, 2025
28 checks passed
@carolynzech carolynzech deleted the contracts-as-assertions branch January 9, 2025 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-BenchCI Tag a PR to run benchmark CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an option to turn contract clauses into assertions
3 participants