diff options
| author | Frank Steffahn <frank.steffahn@stu.uni-kiel.de> | 2021-07-01 19:12:13 +0200 |
|---|---|---|
| committer | Frank Steffahn <frank.steffahn@stu.uni-kiel.de> | 2021-07-28 14:33:36 +0200 |
| commit | 89583e98e8b79c62ec70d791c9d4453decce1b5b (patch) | |
| tree | 5191ff12a14af7fb36e27aeb5faf84f6de387398 /library/alloc/src/vec | |
| parent | 9ff421da992d6612eb43fb58014f83ce15168146 (diff) | |
| download | rust-89583e98e8b79c62ec70d791c9d4453decce1b5b.tar.gz rust-89583e98e8b79c62ec70d791c9d4453decce1b5b.zip | |
Make `SpecInPlaceCollect` use `TrustedRandomAccessNoCoerce`
Diffstat (limited to 'library/alloc/src/vec')
| -rw-r--r-- | library/alloc/src/vec/source_iter_marker.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/library/alloc/src/vec/source_iter_marker.rs b/library/alloc/src/vec/source_iter_marker.rs index d814d4ae355..4c06c044e1a 100644 --- a/library/alloc/src/vec/source_iter_marker.rs +++ b/library/alloc/src/vec/source_iter_marker.rs @@ -1,4 +1,4 @@ -use core::iter::{InPlaceIterable, SourceIter, TrustedRandomAccess}; +use core::iter::{InPlaceIterable, SourceIter, TrustedRandomAccessNoCoerce}; use core::mem::{self, ManuallyDrop}; use core::ptr::{self}; @@ -101,6 +101,8 @@ fn write_in_place_with_drop<T>( trait SpecInPlaceCollect<T, I>: Iterator<Item = T> { /// Collects an iterator (`self`) into the destination buffer (`dst`) and returns the number of items /// collected. `end` is the last writable element of the allocation and used for bounds checks. + // FIXME: Clarify safety conditions. Iterator must not be coerced to a subtype + // after this call due to potential use of [`TrustedRandomAccessNoCoerce`]. fn collect_in_place(&mut self, dst: *mut T, end: *const T) -> usize; } @@ -124,7 +126,7 @@ where impl<T, I> SpecInPlaceCollect<T, I> for I where - I: Iterator<Item = T> + TrustedRandomAccess, + I: Iterator<Item = T> + TrustedRandomAccessNoCoerce, { #[inline] fn collect_in_place(&mut self, dst_buf: *mut T, end: *const T) -> usize { |
