Skip to content

Commit d9095e5

Browse files
combine 2 challenges
1 parent a9cfdf4 commit d9095e5

2 files changed

Lines changed: 66 additions & 92 deletions

File tree

doc/src/challenges/0018-slice-iter-pt1.md

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Challenge 18: Verify the safety of `slice` iter functions - part 1
1+
# Challenge 18: Verify the safety of `slice` iter functions
22

33
- **Status:** Open
44
- **Tracking Issue:** [#282](https://github.com/model-checking/verify-rust-std/issues/282)
@@ -10,7 +10,7 @@
1010

1111

1212
## Goal
13-
13+
**Part 1:**
1414
Verify the safety of Iterator functions of `std::slice` generated by `iterator!` and `forward_iterator!` macros that are defined in (library/core/src/slice/iter/macros.rs):
1515
to generate impl for Iter, IterMut, SplitN, SplitNMut, RSplitN, RSplitNMut in (library/core/src/slice/iter.rs):
1616

@@ -33,16 +33,18 @@ forward_iterator! { SplitNMut: T, &'a mut [T] }
3333
forward_iterator! { RSplitNMut: T, &'a mut [T] }
3434
```
3535

36+
**Part 2:**
37+
Verify the safety of Iterator functions of `std::slice` that are defined in (library/core/src/slice/iter.rs).
38+
3639
### Success Criteria
3740

38-
Write and prove the contract for the safety of the following functions:
41+
**Part 1:** In (library/core/src/slice/iter/macros.rs)
42+
43+
Prove absence of undefined behaviors of following safe functions that contain unsafe code:
3944

4045
| Function |
4146
|---------|
42-
|next_back_unchecked|
4347
|make_slice|
44-
|pre_dec_end|
45-
|post_inc_start|
4648
|len|
4749
|is_empty|
4850
|next|
@@ -62,7 +64,64 @@ Write and prove the contract for the safety of the following functions:
6264
|next_back|
6365
|nth_back|
6466
|advance_back_by|
65-
|next_unchecked|
67+
68+
69+
**Part 2:** In (library/core/src/slice/iter.rs)
70+
71+
Write and prove the contract for the safety of the following unsafe functions:
72+
73+
| Function | Impl for |
74+
|---------| ---------|
75+
|__iterator_get_unchecked| Windows|
76+
|__iterator_get_unchecked| Chunks|
77+
|__iterator_get_unchecked| ChunksMut|
78+
|__iterator_get_unchecked| ChunksExact|
79+
|__iterator_get_unchecked| ChunksExact|
80+
|__iterator_get_unchecked| ArrayChunks|
81+
|__iterator_get_unchecked| ArrayChunksMut|
82+
|__iterator_get_unchecked| RChunks|
83+
|__iterator_get_unchecked| RChunksMut|
84+
|__iterator_get_unchecked| RChunksExact|
85+
|__iterator_get_unchecked| RChunksExactMut|
86+
87+
Prove absence of undefined behaviors of following safe functions that contain unsafe code:
88+
89+
| Function | Impl for |
90+
|---------| ---------|
91+
|new| Iter|
92+
|new| IterMut|
93+
|into_slice| IterMut|
94+
|as_mut_slice| IterMut|
95+
|next| Split|
96+
|next_back| Split|
97+
|next_back| Chunks|
98+
|next| ChunksMut|
99+
|nth| ChunksMut|
100+
|next_back| ChunksMut|
101+
|nth_back| ChunksMut|
102+
|new| ChunksExact|
103+
|new| ChunksExactMut|
104+
|next| ChunksExactMut|
105+
|nth| ChunksExactMut|
106+
|next_back| ChunksExactMut|
107+
|nth_back| ChunksExactMut|
108+
|next| ArrayWindows|
109+
|nth| ArrayWindows|
110+
|next_back| ArrayWindows|
111+
|nth_back| ArrayWindows|
112+
|next| RChunks|
113+
|next_back| RChunks|
114+
|next| RChunksMut|
115+
|nth| RChunksMut|
116+
|last| RChunksMut|
117+
|next_back| RChunksMut|
118+
|nth_back| RChunksMut|
119+
|new| RChunksExact|
120+
|new| RChunksExactMut|
121+
|next| RChunksExactMut|
122+
|nth| RChunksExactMut|
123+
|next_back| RChunksExactMut|
124+
|nth_back| RChunksExactMut|
66125

67126

68127
The verification must be unbounded---it must hold for slices of arbitrary length.

doc/src/challenges/0019-slice-iter-pt2.md

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)