diff options
| -rw-r--r-- | library/alloc/src/collections/vec_deque/iter.rs | 8 | ||||
| -rw-r--r-- | library/alloc/src/collections/vec_deque/iter_mut.rs | 8 | ||||
| -rw-r--r-- | library/core/src/iter/adapters/cloned.rs | 12 | ||||
| -rw-r--r-- | library/core/src/iter/adapters/copied.rs | 12 | ||||
| -rw-r--r-- | library/core/src/iter/adapters/enumerate.rs | 12 | ||||
| -rw-r--r-- | library/core/src/iter/adapters/fuse.rs | 9 | ||||
| -rw-r--r-- | library/core/src/iter/adapters/map.rs | 12 | ||||
| -rw-r--r-- | library/core/src/iter/adapters/mod.rs | 3 | ||||
| -rw-r--r-- | library/core/src/iter/adapters/zip.rs | 23 | ||||
| -rw-r--r-- | library/core/src/iter/mod.rs | 2 | ||||
| -rw-r--r-- | library/core/src/iter/range.rs | 10 | ||||
| -rw-r--r-- | library/core/src/slice/iter.rs | 80 | ||||
| -rw-r--r-- | library/core/src/str/iter.rs | 8 |
13 files changed, 160 insertions, 39 deletions
diff --git a/library/alloc/src/collections/vec_deque/iter.rs b/library/alloc/src/collections/vec_deque/iter.rs index ae1b03c9a4d..3fa5bb6bff0 100644 --- a/library/alloc/src/collections/vec_deque/iter.rs +++ b/library/alloc/src/collections/vec_deque/iter.rs @@ -1,5 +1,5 @@ use core::fmt; -use core::iter::{FusedIterator, TrustedLen, TrustedRandomAccess}; +use core::iter::{FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; use core::ops::Try; use super::{count, wrap_index, RingSlices}; @@ -177,6 +177,10 @@ unsafe impl<T> TrustedLen for Iter<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<T> TrustedRandomAccess for Iter<'_, T> { +unsafe impl<T> TrustedRandomAccess for Iter<'_, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<T> TrustedRandomAccessNoCoerce for Iter<'_, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } diff --git a/library/alloc/src/collections/vec_deque/iter_mut.rs b/library/alloc/src/collections/vec_deque/iter_mut.rs index df30c38652f..5974d480cf0 100644 --- a/library/alloc/src/collections/vec_deque/iter_mut.rs +++ b/library/alloc/src/collections/vec_deque/iter_mut.rs @@ -1,5 +1,5 @@ use core::fmt; -use core::iter::{FusedIterator, TrustedLen, TrustedRandomAccess}; +use core::iter::{FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; use core::marker::PhantomData; use super::{count, wrap_index, RingSlices}; @@ -146,6 +146,10 @@ unsafe impl<T> TrustedLen for IterMut<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<T> TrustedRandomAccess for IterMut<'_, T> { +unsafe impl<T> TrustedRandomAccess for IterMut<'_, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<T> TrustedRandomAccessNoCoerce for IterMut<'_, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } diff --git a/library/core/src/iter/adapters/cloned.rs b/library/core/src/iter/adapters/cloned.rs index 5cd65a9415f..857aec292e0 100644 --- a/library/core/src/iter/adapters/cloned.rs +++ b/library/core/src/iter/adapters/cloned.rs @@ -1,4 +1,6 @@ -use crate::iter::adapters::{zip::try_get_unchecked, TrustedRandomAccess}; +use crate::iter::adapters::{ + zip::try_get_unchecked, TrustedRandomAccess, TrustedRandomAccessNoCoerce, +}; use crate::iter::{FusedIterator, TrustedLen}; use crate::ops::Try; @@ -121,9 +123,13 @@ where #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<I> TrustedRandomAccess for Cloned<I> +unsafe impl<I> TrustedRandomAccess for Cloned<I> where I: TrustedRandomAccess {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<I> TrustedRandomAccessNoCoerce for Cloned<I> where - I: TrustedRandomAccess, + I: TrustedRandomAccessNoCoerce, { const MAY_HAVE_SIDE_EFFECT: bool = true; } diff --git a/library/core/src/iter/adapters/copied.rs b/library/core/src/iter/adapters/copied.rs index 07a3b5d2456..8351f95592d 100644 --- a/library/core/src/iter/adapters/copied.rs +++ b/library/core/src/iter/adapters/copied.rs @@ -1,4 +1,6 @@ -use crate::iter::adapters::{zip::try_get_unchecked, TrustedRandomAccess}; +use crate::iter::adapters::{ + zip::try_get_unchecked, TrustedRandomAccess, TrustedRandomAccessNoCoerce, +}; use crate::iter::{FusedIterator, TrustedLen}; use crate::ops::Try; @@ -137,9 +139,13 @@ where #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<I> TrustedRandomAccess for Copied<I> +unsafe impl<I> TrustedRandomAccess for Copied<I> where I: TrustedRandomAccess {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<I> TrustedRandomAccessNoCoerce for Copied<I> where - I: TrustedRandomAccess, + I: TrustedRandomAccessNoCoerce, { const MAY_HAVE_SIDE_EFFECT: bool = I::MAY_HAVE_SIDE_EFFECT; } diff --git a/library/core/src/iter/adapters/enumerate.rs b/library/core/src/iter/adapters/enumerate.rs index 8b27bdc60a7..692a170f41b 100644 --- a/library/core/src/iter/adapters/enumerate.rs +++ b/library/core/src/iter/adapters/enumerate.rs @@ -1,4 +1,6 @@ -use crate::iter::adapters::{zip::try_get_unchecked, SourceIter, TrustedRandomAccess}; +use crate::iter::adapters::{ + zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce, +}; use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen}; use crate::ops::Try; @@ -207,9 +209,13 @@ where #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<I> TrustedRandomAccess for Enumerate<I> +unsafe impl<I> TrustedRandomAccess for Enumerate<I> where I: TrustedRandomAccess {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<I> TrustedRandomAccessNoCoerce for Enumerate<I> where - I: TrustedRandomAccess, + I: TrustedRandomAccessNoCoerce, { const MAY_HAVE_SIDE_EFFECT: bool = I::MAY_HAVE_SIDE_EFFECT; } diff --git a/library/core/src/iter/adapters/fuse.rs b/library/core/src/iter/adapters/fuse.rs index 408328adeec..febb8418baf 100644 --- a/library/core/src/iter/adapters/fuse.rs +++ b/library/core/src/iter/adapters/fuse.rs @@ -2,6 +2,7 @@ use crate::intrinsics; use crate::iter::adapters::zip::try_get_unchecked; use crate::iter::{ DoubleEndedIterator, ExactSizeIterator, FusedIterator, TrustedLen, TrustedRandomAccess, + TrustedRandomAccessNoCoerce, }; use crate::ops::Try; @@ -221,9 +222,13 @@ unsafe impl<I> TrustedLen for Fuse<I> where I: TrustedLen {} // // This is safe to implement as `Fuse` is just forwarding these to the wrapped iterator `I`, which // preserves these properties. -unsafe impl<I> TrustedRandomAccess for Fuse<I> +unsafe impl<I> TrustedRandomAccess for Fuse<I> where I: TrustedRandomAccess {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<I> TrustedRandomAccessNoCoerce for Fuse<I> where - I: TrustedRandomAccess, + I: TrustedRandomAccessNoCoerce, { const MAY_HAVE_SIDE_EFFECT: bool = I::MAY_HAVE_SIDE_EFFECT; } diff --git a/library/core/src/iter/adapters/map.rs b/library/core/src/iter/adapters/map.rs index dc86eccfcb8..c6b26d830e7 100644 --- a/library/core/src/iter/adapters/map.rs +++ b/library/core/src/iter/adapters/map.rs @@ -1,5 +1,7 @@ use crate::fmt; -use crate::iter::adapters::{zip::try_get_unchecked, SourceIter, TrustedRandomAccess}; +use crate::iter::adapters::{ + zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce, +}; use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen}; use crate::ops::Try; @@ -187,9 +189,13 @@ where #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<I, F> TrustedRandomAccess for Map<I, F> +unsafe impl<I, F> TrustedRandomAccess for Map<I, F> where I: TrustedRandomAccess {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<I, F> TrustedRandomAccessNoCoerce for Map<I, F> where - I: TrustedRandomAccess, + I: TrustedRandomAccessNoCoerce, { const MAY_HAVE_SIDE_EFFECT: bool = true; } diff --git a/library/core/src/iter/adapters/mod.rs b/library/core/src/iter/adapters/mod.rs index a3fbf4d9c38..056ccca1d01 100644 --- a/library/core/src/iter/adapters/mod.rs +++ b/library/core/src/iter/adapters/mod.rs @@ -51,6 +51,9 @@ pub use self::map_while::MapWhile; #[unstable(feature = "trusted_random_access", issue = "none")] pub use self::zip::TrustedRandomAccess; +#[unstable(feature = "trusted_random_access", issue = "none")] +pub use self::zip::TrustedRandomAccessNoCoerce; + #[unstable(feature = "iter_zip", issue = "83574")] pub use self::zip::zip; diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs index bf45f36dcf1..9333cd0f283 100644 --- a/library/core/src/iter/adapters/zip.rs +++ b/library/core/src/iter/adapters/zip.rs @@ -355,6 +355,15 @@ where A: TrustedRandomAccess, B: TrustedRandomAccess, { +} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<A, B> TrustedRandomAccessNoCoerce for Zip<A, B> +where + A: TrustedRandomAccessNoCoerce, + B: TrustedRandomAccessNoCoerce, +{ const MAY_HAVE_SIDE_EFFECT: bool = A::MAY_HAVE_SIDE_EFFECT || B::MAY_HAVE_SIDE_EFFECT; } @@ -431,7 +440,7 @@ impl<A: Debug + TrustedRandomAccess, B: Debug + TrustedRandomAccess> ZipFmt<A, B /// /// The iterator's `size_hint` must be exact and cheap to call. /// -/// `size` may not be overridden. +/// `TrustedRandomAccessNoCoerce::size` may not be overridden. /// /// All subtypes and all supertypes of `Self` must also implement `TrustedRandomAccess`. /// In particular, this means that types with non-invariant parameters usually can not have @@ -455,7 +464,7 @@ impl<A: Debug + TrustedRandomAccess, B: Debug + TrustedRandomAccess> ZipFmt<A, B /// * `std::iter::Iterator::size_hint` /// * `std::iter::DoubleEndedIterator::next_back` /// * `std::iter::Iterator::__iterator_get_unchecked` -/// * `std::iter::TrustedRandomAccess::size` +/// * `std::iter::TrustedRandomAccessNoCoerce::size` /// 5. If `T` is a subtype of `Self`, then `self` is allowed to be coerced /// to `T`. If `self` is coerced to `T` after `self.__iterator_get_unchecked(idx)` has already /// been called, then no methods except for the ones listed under 4. are allowed to be called @@ -474,7 +483,15 @@ impl<A: Debug + TrustedRandomAccess, B: Debug + TrustedRandomAccess> ZipFmt<A, B #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] #[rustc_specialization_trait] -pub unsafe trait TrustedRandomAccess: Sized { +pub unsafe trait TrustedRandomAccess: TrustedRandomAccessNoCoerce {} + +/// Like [`TrustedRandomAccess`] but without any of the requirements / guarantees around +/// coercions to subtypes after `__iterator_get_unchecked` (they aren’t allowed here!), and +/// without the requirement that subtypes / supertypes implement [`TrustedRandomAccessNoCoerce`]. +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +#[rustc_specialization_trait] +pub unsafe trait TrustedRandomAccessNoCoerce: Sized { // Convenience method. fn size(&self) -> usize where diff --git a/library/core/src/iter/mod.rs b/library/core/src/iter/mod.rs index bfb27da505e..5f664b5f4a8 100644 --- a/library/core/src/iter/mod.rs +++ b/library/core/src/iter/mod.rs @@ -407,6 +407,8 @@ pub use self::adapters::SourceIter; pub use self::adapters::StepBy; #[unstable(feature = "trusted_random_access", issue = "none")] pub use self::adapters::TrustedRandomAccess; +#[unstable(feature = "trusted_random_access", issue = "none")] +pub use self::adapters::TrustedRandomAccessNoCoerce; #[stable(feature = "rust1", since = "1.0.0")] pub use self::adapters::{ Chain, Cycle, Enumerate, Filter, FilterMap, FlatMap, Fuse, Inspect, Map, Peekable, Rev, Scan, diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index b9387ef49e5..c3febd88ac9 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs @@ -3,7 +3,9 @@ use crate::convert::TryFrom; use crate::mem; use crate::ops::{self, Try}; -use super::{FusedIterator, TrustedLen, TrustedRandomAccess, TrustedStep}; +use super::{ + FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, TrustedStep, +}; // Safety: All invariants are upheld. macro_rules! unsafe_impl_trusted_step { @@ -495,7 +497,11 @@ macro_rules! unsafe_range_trusted_random_access_impl { ($($t:ty)*) => ($( #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] - unsafe impl TrustedRandomAccess for ops::Range<$t> { + unsafe impl TrustedRandomAccess for ops::Range<$t> {} + + #[doc(hidden)] + #[unstable(feature = "trusted_random_access", issue = "none")] + unsafe impl TrustedRandomAccessNoCoerce for ops::Range<$t> { const MAY_HAVE_SIDE_EFFECT: bool = false; } )*) diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index 5cbc6343e3a..419bf0e292a 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -8,7 +8,7 @@ use crate::cmp; use crate::cmp::Ordering; use crate::fmt; use crate::intrinsics::{assume, exact_div, unchecked_sub}; -use crate::iter::{FusedIterator, TrustedLen, TrustedRandomAccess}; +use crate::iter::{FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; use crate::marker::{PhantomData, Send, Sized, Sync}; use crate::mem; use crate::num::NonZeroUsize; @@ -1312,7 +1312,11 @@ impl<T> FusedIterator for Windows<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<'a, T> TrustedRandomAccess for Windows<'a, T> { +unsafe impl<'a, T> TrustedRandomAccess for Windows<'a, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<'a, T> TrustedRandomAccessNoCoerce for Windows<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -1477,7 +1481,11 @@ impl<T> FusedIterator for Chunks<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<'a, T> TrustedRandomAccess for Chunks<'a, T> { +unsafe impl<'a, T> TrustedRandomAccess for Chunks<'a, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<'a, T> TrustedRandomAccessNoCoerce for Chunks<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -1639,7 +1647,11 @@ impl<T> FusedIterator for ChunksMut<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<'a, T> TrustedRandomAccess for ChunksMut<'a, T> { +unsafe impl<'a, T> TrustedRandomAccess for ChunksMut<'a, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<'a, T> TrustedRandomAccessNoCoerce for ChunksMut<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -1793,7 +1805,11 @@ impl<T> FusedIterator for ChunksExact<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<'a, T> TrustedRandomAccess for ChunksExact<'a, T> { +unsafe impl<'a, T> TrustedRandomAccess for ChunksExact<'a, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<'a, T> TrustedRandomAccessNoCoerce for ChunksExact<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -1944,7 +1960,11 @@ impl<T> FusedIterator for ChunksExactMut<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<'a, T> TrustedRandomAccess for ChunksExactMut<'a, T> { +unsafe impl<'a, T> TrustedRandomAccess for ChunksExactMut<'a, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<'a, T> TrustedRandomAccessNoCoerce for ChunksExactMut<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -2182,7 +2202,11 @@ impl<T, const N: usize> FusedIterator for ArrayChunks<'_, T, N> {} #[doc(hidden)] #[unstable(feature = "array_chunks", issue = "74985")] -unsafe impl<'a, T, const N: usize> TrustedRandomAccess for ArrayChunks<'a, T, N> { +unsafe impl<'a, T, const N: usize> TrustedRandomAccess for ArrayChunks<'a, T, N> {} + +#[doc(hidden)] +#[unstable(feature = "array_chunks", issue = "74985")] +unsafe impl<'a, T, const N: usize> TrustedRandomAccessNoCoerce for ArrayChunks<'a, T, N> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -2295,7 +2319,11 @@ impl<T, const N: usize> FusedIterator for ArrayChunksMut<'_, T, N> {} #[doc(hidden)] #[unstable(feature = "array_chunks", issue = "74985")] -unsafe impl<'a, T, const N: usize> TrustedRandomAccess for ArrayChunksMut<'a, T, N> { +unsafe impl<'a, T, const N: usize> TrustedRandomAccess for ArrayChunksMut<'a, T, N> {} + +#[doc(hidden)] +#[unstable(feature = "array_chunks", issue = "74985")] +unsafe impl<'a, T, const N: usize> TrustedRandomAccessNoCoerce for ArrayChunksMut<'a, T, N> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -2457,7 +2485,11 @@ impl<T> FusedIterator for RChunks<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<'a, T> TrustedRandomAccess for RChunks<'a, T> { +unsafe impl<'a, T> TrustedRandomAccess for RChunks<'a, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<'a, T> TrustedRandomAccessNoCoerce for RChunks<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -2618,7 +2650,11 @@ impl<T> FusedIterator for RChunksMut<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<'a, T> TrustedRandomAccess for RChunksMut<'a, T> { +unsafe impl<'a, T> TrustedRandomAccess for RChunksMut<'a, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<'a, T> TrustedRandomAccessNoCoerce for RChunksMut<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -2776,7 +2812,11 @@ impl<T> FusedIterator for RChunksExact<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<'a, T> TrustedRandomAccess for RChunksExact<'a, T> { +unsafe impl<'a, T> TrustedRandomAccess for RChunksExact<'a, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<'a, T> TrustedRandomAccessNoCoerce for RChunksExact<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } @@ -2931,19 +2971,31 @@ impl<T> FusedIterator for RChunksExactMut<'_, T> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<'a, T> TrustedRandomAccess for RChunksExactMut<'a, T> { +unsafe impl<'a, T> TrustedRandomAccess for RChunksExactMut<'a, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<'a, T> TrustedRandomAccessNoCoerce for RChunksExactMut<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<'a, T> TrustedRandomAccess for Iter<'a, T> { +unsafe impl<'a, T> TrustedRandomAccess for Iter<'a, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<'a, T> TrustedRandomAccessNoCoerce for Iter<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl<'a, T> TrustedRandomAccess for IterMut<'a, T> { +unsafe impl<'a, T> TrustedRandomAccess for IterMut<'a, T> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl<'a, T> TrustedRandomAccessNoCoerce for IterMut<'a, T> { const MAY_HAVE_SIDE_EFFECT: bool = false; } diff --git a/library/core/src/str/iter.rs b/library/core/src/str/iter.rs index a5774764573..8db9edc6147 100644 --- a/library/core/src/str/iter.rs +++ b/library/core/src/str/iter.rs @@ -2,9 +2,9 @@ use crate::char; use crate::fmt::{self, Write}; -use crate::iter::TrustedRandomAccess; use crate::iter::{Chain, FlatMap, Flatten}; use crate::iter::{Copied, Filter, FusedIterator, Map, TrustedLen}; +use crate::iter::{TrustedRandomAccess, TrustedRandomAccessNoCoerce}; use crate::ops::Try; use crate::option; use crate::slice::{self, Split as SliceSplit}; @@ -345,7 +345,11 @@ unsafe impl TrustedLen for Bytes<'_> {} #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -unsafe impl TrustedRandomAccess for Bytes<'_> { +unsafe impl TrustedRandomAccess for Bytes<'_> {} + +#[doc(hidden)] +#[unstable(feature = "trusted_random_access", issue = "none")] +unsafe impl TrustedRandomAccessNoCoerce for Bytes<'_> { const MAY_HAVE_SIDE_EFFECT: bool = false; } |
