Rollup merge of #52502 - RalfJung:rotate, r=scottmcm
fix unsafety: don't call ptr_rotate for ZST `rotate::ptr_rotate` has a comment saying ``` /// # Safety /// /// The specified range must be valid for reading and writing. /// The type `T` must have non-zero size. ``` So we better make sure we don't call it on ZST... Cc @scottmcm (author of https://github.com/rust-lang/rust/pull/41670)
This commit is contained in:
commit
c74ff6cbd4
1 changed files with 1 additions and 1 deletions
|
@ -48,7 +48,6 @@ impl<T> RawArray<T> {
|
|||
/// # Safety
|
||||
///
|
||||
/// The specified range must be valid for reading and writing.
|
||||
/// The type `T` must have non-zero size.
|
||||
///
|
||||
/// # Algorithm
|
||||
///
|
||||
|
@ -73,6 +72,7 @@ pub unsafe fn ptr_rotate<T>(mut left: usize, mid: *mut T, mut right: usize) {
|
|||
loop {
|
||||
let delta = cmp::min(left, right);
|
||||
if delta <= RawArray::<T>::cap() {
|
||||
// We will always hit this immediately for ZST.
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue