-
Notifications
You must be signed in to change notification settings - Fork 89
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
Implement #[kani::async_proof]
attribute
#1430
Conversation
#[kani::async_proof]
attribute
let attrs = fn_item.attrs; | ||
let vis = fn_item.vis; | ||
let sig = fn_item.sig; | ||
assert!(sig.asyncness.is_some(), "#[kani::async_proof] can only be applied to async functions"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably have a test for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
library/kani_macros/src/lib.rs
Outdated
#[cfg(kani)] | ||
#[proc_macro_attribute] | ||
pub fn async_proof(attr: TokenStream, item: TokenStream) -> TokenStream { | ||
assert!(attr.to_string().is_empty(), "#[kani::async_proof] does not take any arguments"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true for now, but will probably not be true in the future if we want to control which executor we use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I'll mention that this may change in the future.
|
||
#[cfg(kani)] | ||
#[proc_macro_attribute] | ||
pub fn async_proof(attr: TokenStream, item: TokenStream) -> TokenStream { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro is more extensive than some of the others, and could probably use a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
Do we actually need a separate attribute for async? Couldn't the existing |
@camshaft Thanks for the suggestion! I had considered that, but thought it would be better to keep them separate: we expect to extend the attribute later on to allow the user to choose different Kani executors: |
Opened #1464 to discuss |
Description of changes:
This adds an attribute
#[kani::async_proof]
to make model-checkingasync
functions more ergonomic. Before, one had to manually callkani::block_on
on anasync
function.Call-outs:
This adds the dependencies
syn
andquote
tokani_macros
.Testing:
How is this change tested? Added a regression test.
Is this a refactor change? No
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.