Skip to content

Support struct field accessing in loop contracts #3700

Closed
@qinheping

Description

@qinheping

Requested feature: Support of using struct.field in loop contracts
Use case: #[kani::loop_invariant(h.x == 2)]
Link to relevant documentation (Rust reference, Nomicon, RFC): #3167

Test case:

struct hole{
    x: u8
}

#[kani::proof]
fn simple_while_loop_harness() {
    let mut h: hole = hole{ x: kani::any_where(|i| *i >= 2)};
    #[kani::loop_invariant(h.x == 2)]
    while h.x > 2 {
        h.x = h.x - 1;
    }

    assert!(h.x == 2);
}

Metadata

Metadata

Assignees

Labels

[C] Feature / EnhancementA new feature request or enhancement to an existing feature.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions