Skip to content

Commit

Permalink
Fix miri errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Jan 24, 2024
1 parent 46f2451 commit 29e1279
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/vec/drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ impl<T, const N: usize> Drop for Drain<'_, T, N> {
let start = source_vec.len();
let tail = self.0.tail_start;
if tail != start {
let src = source_vec.as_ptr().add(tail);
let dst = source_vec.as_mut_ptr().add(start);
let src = source_vec.as_ptr().add(tail);
ptr::copy(src, dst, self.0.tail_len);
}
source_vec.set_len(start + self.0.tail_len);
Expand Down
5 changes: 3 additions & 2 deletions src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,13 @@ impl<T, const N: usize> Vec<T, N> {
unsafe {
// Set `self.vec` length's to `start`, to be safe in case `Drain` is leaked.
self.set_len(start);
let range_slice = slice::from_raw_parts(self.as_ptr().add(start), end - start);
let vec = NonNull::from(self);
let range_slice = slice::from_raw_parts(vec.as_ref().as_ptr().add(start), end - start);
Drain {
tail_start: end,
tail_len: len - end,
iter: range_slice.iter(),
vec: NonNull::from(self),
vec,
}
}
}
Expand Down

0 comments on commit 29e1279

Please sign in to comment.