diff options
| author | kennytm <kennytm@gmail.com> | 2018-07-21 02:59:04 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-07-21 04:08:05 +0800 |
| commit | c74ff6cbd45ee79d623a6e1ad936d851c34fffc8 (patch) | |
| tree | 85b6e91f265435ee01916b0e5ba6ba4f8d002298 | |
| parent | 509cbf3e8ecf1cf92b7051fa54e9360ad7b7449f (diff) | |
| parent | 16c057256f68b39df70737838f367cf645d6e0c7 (diff) | |
| download | rust-c74ff6cbd45ee79d623a6e1ad936d851c34fffc8.tar.gz rust-c74ff6cbd45ee79d623a6e1ad936d851c34fffc8.zip | |
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)
| -rw-r--r-- | src/libcore/slice/rotate.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcore/slice/rotate.rs b/src/libcore/slice/rotate.rs index e4a4e33c172..28ef53ccb5c 100644 --- a/src/libcore/slice/rotate.rs +++ b/src/libcore/slice/rotate.rs @@ -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; } |
