File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -2985,8 +2985,14 @@ impl<T> Iterator for IntoIter<T> {
29852985 where
29862986 Self : TrustedRandomAccess ,
29872987 {
2988- // SAFETY: the caller must uphold the contract for
2989- // `Iterator::get_unchecked`.
2988+ // SAFETY: the caller must guarantee that `i` is in bounds of the
2989+ // `Vec<T>`, so `i` cannot overflow an `isize`, and the `self.ptr.add(i)`
2990+ // is guaranteed to pointer to an element of the `Vec<T>` and
2991+ // thus guaranteed to be valid to dereference.
2992+ //
2993+ // Also note the implementation of `Self: TrustedRandomAccess` requires
2994+ // that `T: Copy` so reading elements from the buffer doesn't invalidate
2995+ // them for `Drop`.
29902996 unsafe {
29912997 if mem:: size_of :: < T > ( ) == 0 { mem:: zeroed ( ) } else { ptr:: read ( self . ptr . add ( i) ) }
29922998 }
You can’t perform that action at this time.
0 commit comments