mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Don't reborrow self when computing the dest pointer in <[T]>::copy_within
This commit is contained in:
parent
13bf0b2a3c
commit
d7341f3c4b
@ -3096,7 +3096,11 @@ impl<T> [T] {
|
||||
// SAFETY: the conditions for `ptr::copy` have all been checked above,
|
||||
// as have those for `ptr::add`.
|
||||
unsafe {
|
||||
ptr::copy(self.as_ptr().add(src_start), self.as_mut_ptr().add(dest), count);
|
||||
// Derive both `src_ptr` and `dest_ptr` from the same loan
|
||||
let ptr = self.as_mut_ptr();
|
||||
let src_ptr = ptr.add(src_start);
|
||||
let dest_ptr = ptr.add(dest);
|
||||
ptr::copy(src_ptr, dest_ptr, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user