Skip to content

Commit 625298b

Browse files
jaisnanadpaco-aws
authored andcommitted
Update Unwind documentation (rust-lang#1087)
* update unwind documentation Co-authored-by: Adrian Palacios <[email protected]>
1 parent 23472fc commit 625298b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

docs/src/cargo-kani.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ You can achieve this by adding the following lines to the package's `Cargo.toml`
2424

2525
```toml
2626
[package.metadata.kani]
27-
flags = { unwind = "5" }
27+
flags = { default-unwind = "5" }
2828
```

docs/src/tutorial-loop-unwinding.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,28 @@ Failed Checks: dereference failure: pointer outside object bounds
7979

8080
Kani is now sure we've unwound the loop enough to verify our proof harness, and now we're seeing just the bound checking failures from the off-by-one error.
8181

82+
## Unwinding value specification
83+
84+
Kani allows three options to specify the unwind value for a particular harness:
85+
86+
1. The unwind annotation `#[kani::unwind(<num>)]`. This sets the unwind value for the harness with the annotation. Example -
87+
``` rust,noplaypen
88+
#[kani::proof]
89+
#[kani::unwind(3)]
90+
fn proof_harness() {
91+
[...]
92+
}
93+
```
94+
2. `--default-unwind` flag. This sets the global or default unwind value for the entire file/crate on which kani or cargo-kani is called. Example -
95+
```
96+
kani file.rs --default-unwind 3
97+
```
98+
3. `--unwind` flag. This overrides any annotation and forces the harness to use the specified value. This needs to be used alongside `--harness` and sets the unwind value for the harness specified. Example -
99+
```
100+
kani file.rs --unwind 2 --harness proof_harness
101+
```
102+
103+
### Exercises -
104+
82105
1. Exercise: Fix the off-by-one bounds error and get Kani to verify successfully.
83106
2. Exercise: After fixing the error, `--default-unwind 11` works. Why?

0 commit comments

Comments
 (0)