diff options
| author | Frank Steffahn <frank.steffahn@stu.uni-kiel.de> | 2021-06-01 02:21:26 +0200 |
|---|---|---|
| committer | Frank Steffahn <frank.steffahn@stu.uni-kiel.de> | 2021-07-21 14:37:23 +0200 |
| commit | 1b66a799c7ef707d2cd4b325b654e69bf536c30f (patch) | |
| tree | f5e24ee9a61aea5093946da3c1e1ccc9a2145ed1 /library/core/src/array | |
| parent | cf932aa584f2ba1a1744f3ef0b21f14387276fb6 (diff) | |
| download | rust-1b66a799c7ef707d2cd4b325b654e69bf536c30f.tar.gz rust-1b66a799c7ef707d2cd4b325b654e69bf536c30f.zip | |
Remove unsound TrustedRandomAccess implementations
Removes the implementations that depend on the user-definable trait `Copy`. Only fix regressions to ensure merge in 1.55: Does not modify `vec::IntoIter`.
Diffstat (limited to 'library/core/src/array')
| -rw-r--r-- | library/core/src/array/iter.rs | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/library/core/src/array/iter.rs b/library/core/src/array/iter.rs index 931ea77eca4..61ab1b1faff 100644 --- a/library/core/src/array/iter.rs +++ b/library/core/src/array/iter.rs @@ -2,7 +2,7 @@ use crate::{ fmt, - iter::{self, ExactSizeIterator, FusedIterator, TrustedLen, TrustedRandomAccess}, + iter::{self, ExactSizeIterator, FusedIterator, TrustedLen}, mem::{self, MaybeUninit}, ops::Range, ptr, @@ -130,19 +130,6 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> { fn last(mut self) -> Option<Self::Item> { self.next_back() } - - #[inline] - #[doc(hidden)] - unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item - where - Self: TrustedRandomAccess, - { - // SAFETY: Callers are only allowed to pass an index that is in bounds - // Additionally Self: TrustedRandomAccess is only implemented for T: Copy which means even - // multiple repeated reads of the same index would be safe and the - // values are !Drop, thus won't suffer from double drops. - unsafe { self.data.get_unchecked(self.alive.start + idx).assume_init_read() } - } } #[stable(feature = "array_value_iter_impls", since = "1.40.0")] @@ -197,17 +184,6 @@ impl<T, const N: usize> FusedIterator for IntoIter<T, N> {} #[stable(feature = "array_value_iter_impls", since = "1.40.0")] unsafe impl<T, const N: usize> TrustedLen for IntoIter<T, N> {} -#[doc(hidden)] -#[unstable(feature = "trusted_random_access", issue = "none")] -// T: Copy as approximation for !Drop since get_unchecked does not update the pointers -// and thus we can't implement drop-handling -unsafe impl<T, const N: usize> TrustedRandomAccess for IntoIter<T, N> -where - T: Copy, -{ - const MAY_HAVE_SIDE_EFFECT: bool = false; -} - #[stable(feature = "array_value_iter_impls", since = "1.40.0")] impl<T: Clone, const N: usize> Clone for IntoIter<T, N> { fn clone(&self) -> Self { |
