Skip to content

Commit c74ff6c

Browse files
committed
Rollup merge of rust-lang#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 rust-lang#41670)
2 parents 509cbf3 + 16c0572 commit c74ff6c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libcore/slice/rotate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ impl<T> RawArray<T> {
4848
/// # Safety
4949
///
5050
/// The specified range must be valid for reading and writing.
51-
/// The type `T` must have non-zero size.
5251
///
5352
/// # Algorithm
5453
///
@@ -73,6 +72,7 @@ pub unsafe fn ptr_rotate<T>(mut left: usize, mid: *mut T, mut right: usize) {
7372
loop {
7473
let delta = cmp::min(left, right);
7574
if delta <= RawArray::<T>::cap() {
75+
// We will always hit this immediately for ZST.
7676
break;
7777
}
7878

0 commit comments

Comments
 (0)