|
1 | 1 | //! Defines the `IntoIter` owned iterator for arrays. |
2 | 2 |
|
| 3 | +use safety::{ensures,requires}; |
| 4 | +#[cfg(kani)] |
| 5 | +use crate::kani; |
| 6 | +#[allow(unused_imports)] |
| 7 | +use crate::ub_checks::*; |
| 8 | + |
3 | 9 | use crate::intrinsics::transmute_unchecked; |
4 | 10 | use crate::iter::{FusedIterator, TrustedLen, TrustedRandomAccessNoCoerce}; |
5 | 11 | use crate::mem::MaybeUninit; |
@@ -138,6 +144,8 @@ impl<T, const N: usize> IntoIter<T, N> { |
138 | 144 | /// ``` |
139 | 145 | #[unstable(feature = "array_into_iter_constructors", issue = "91583")] |
140 | 146 | #[inline] |
| 147 | + #[requires(initialized.start <= initialized.end)] |
| 148 | + #[requires(initialized.end <= N)] |
141 | 149 | pub const unsafe fn new_unchecked( |
142 | 150 | buffer: [MaybeUninit<T>; N], |
143 | 151 | initialized: Range<usize>, |
@@ -279,6 +287,8 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> { |
279 | 287 | } |
280 | 288 |
|
281 | 289 | #[inline] |
| 290 | + #[requires(idx < self.len())] |
| 291 | + #[cfg_attr(kani, kani::modifies(self))] |
282 | 292 | unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item { |
283 | 293 | // SAFETY: The caller must provide an idx that is in bound of the remainder. |
284 | 294 | let elem_ref = unsafe { self.as_mut_slice().get_unchecked_mut(idx) }; |
|
0 commit comments