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 basic support for async/.await #1414

Merged
merged 3 commits into from
Jul 28, 2022
Merged

Conversation

fzaiser
Copy link
Contributor

@fzaiser fzaiser commented Jul 27, 2022

Description of changes:

This implements the language constructs async and .await. Since they are lowered to generators in the Rust MIR, #1378 did most of the heavy lifting. The only necessary change was to stop ignoring the std::future::from_generator function, which turns a generator into a future. Kani can compile it successfully now.

Call-outs:

To test this, I had to add a function poll_loop, which repeatedly polls a future until it completes. We'd probably want to keep such a function in the kani library under kani::async_await. But this PR is intentionally minimal and leaves such improvements for later.

Testing:

  • How is this change tested? Added a test for both async { ... } blocks and async fn functions.

  • Is this a refactor change? No.

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

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

@fzaiser fzaiser requested a review from a team as a code owner July 27, 2022 22:50
@fzaiser fzaiser self-assigned this Jul 27, 2022
Copy link
Contributor

@celinval celinval left a comment

Choose a reason for hiding this comment

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

It looks good to me. Just some minor comments.

tests/kani/AsyncAwait/main.rs Show resolved Hide resolved
tests/kani/AsyncAwait/main.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.

Awesome!

scripts/kani-fmt.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@tedinski tedinski left a comment

Choose a reason for hiding this comment

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

well I don't want to be left out of the approval chain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants