Commit 3a967e3
authored
Contracts & Harnesses for
Towards #59
### Changes
* Added contracts for `wrapping_shl` (located in
`library/core/src/num/int_macros.rs` and `uint_macros.rs`)
* Added a macro for generating wrapping_{shl, shr} harnesses
* Added harnesses for `wrapping_shl` of each integer type
* `i8`, `i16`, `i32`, `i64`, `i128`, `isize`, `u8`, `u16`, `u32`, `u64`,
`u128`, `usize` --- 12 harnesses in total.
### Revalidation
1. Per the discussion in #59, we have to **build and run Kani from
`feature/verify-rust-std` branch**.
2. To revalidate the verification results, run the following command.
`<harness_to_run>` can be either `num::verify` to run all harnesses or
`num::verify::<harness_name>` (e.g. `checked_wrapping_shl_i8`) to run a
specific harness.
```
kani verify-std "path/to/library" \
--harness <harness_to_run> \
-Z unstable-options \
-Z function-contracts \
-Z mem-predicates
```
All harnesses should pass the default checks (1251 checks where 1
unreachable).
```
SUMMARY:
** 0 of 1251 failed (1 unreachable)
VERIFICATION:- SUCCESSFUL
Verification Time: 2.4682913s
Complete - 1 successfully verified harnesses, 0 failures, 1 total.
```
Example of the unreachable check:
```
Check 123: num::<impl i8>::wrapping_shl.assertion.1
- Status: UNREACHABLE
- Description: "attempt to subtract with overflow"
- Location: library/core/src/num/int_macros.rs:2172:42 in function num::<impl i8>::wrapping_shl
```
### Questions
1. Should we add `requires` (and `ensures`) for `wrapping_shl` given
that `unchecked_shl` already has a `requires`?
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.wrapping_shl (#112)1 parent dc862c4 commit 3a967e3
3 files changed
+40
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2160 | 2160 | | |
2161 | 2161 | | |
2162 | 2162 | | |
| 2163 | + | |
2163 | 2164 | | |
2164 | 2165 | | |
2165 | 2166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1687 | 1687 | | |
1688 | 1688 | | |
1689 | 1689 | | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
1690 | 1703 | | |
1691 | 1704 | | |
1692 | 1705 | | |
| |||
1905 | 1918 | | |
1906 | 1919 | | |
1907 | 1920 | | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
1908 | 1946 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2138 | 2138 | | |
2139 | 2139 | | |
2140 | 2140 | | |
| 2141 | + | |
2141 | 2142 | | |
2142 | 2143 | | |
2143 | 2144 | | |
| |||
0 commit comments