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

Loop contracts in closures and coroutines #3599

Open
qinheping opened this issue Oct 14, 2024 · 0 comments
Open

Loop contracts in closures and coroutines #3599

qinheping opened this issue Oct 14, 2024 · 0 comments
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.

Comments

@qinheping
Copy link
Contributor

Requested feature: Currently loop contracts implementation in #3151 doesn't support loop contracts in closures and coroutines. We want to allow loop contracts be correctly applied in closures and coroutines.
Use case:
Link to relevant documentation (Rust reference, Nomicon, RFC): #3167

Test case:

fn main() {
let mut x: u8 = 11;

let mut res = ||->u8 {    
    #[kani::loop_invariant(x >= 2)]
    while x > 2 {
        x = x - 1;
    }
    x
};

    assert!(res() == 2);
}
@qinheping qinheping added the [C] Feature / Enhancement A new feature request or enhancement to an existing feature. label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.
Projects
None yet
Development

No branches or pull requests

1 participant