diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2021-09-30 21:42:41 +0100 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2021-09-30 21:42:41 +0100 |
| commit | 051d5b0118186433cdb1e12c6198b877bfa0a8fc (patch) | |
| tree | 42e1f4256ebedd1792b20be4c9c8f26cc48dec51 /library/alloc | |
| parent | c8f86cad2dda3181bfedc165d3dd4bf452770228 (diff) | |
| download | rust-051d5b0118186433cdb1e12c6198b877bfa0a8fc.tar.gz rust-051d5b0118186433cdb1e12c6198b877bfa0a8fc.zip | |
Fix standard library for min_specialization changes
Diffstat (limited to 'library/alloc')
| -rw-r--r-- | library/alloc/src/vec/into_iter.rs | 13 | ||||
| -rw-r--r-- | library/alloc/src/vec/source_iter_marker.rs | 16 |
2 files changed, 13 insertions, 16 deletions
diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index 4cb0a4b10bd..096262b41d7 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -220,14 +220,21 @@ unsafe impl<T, A: Allocator> TrustedLen for IntoIter<T, A> {} #[doc(hidden)] #[unstable(issue = "none", feature = "std_internals")] +#[rustc_unsafe_specialization_marker] +pub trait NonDrop {} + // T: Copy as approximation for !Drop since get_unchecked does not advance self.ptr // and thus we can't implement drop-handling -// +#[unstable(issue = "none", feature = "std_internals")] +impl<T: Copy> NonDrop for T {} + +#[doc(hidden)] +#[unstable(issue = "none", feature = "std_internals")] // TrustedRandomAccess (without NoCoerce) must not be implemented because -// subtypes/supertypes of `T` might not be `Copy` +// subtypes/supertypes of `T` might not be `NonDrop` unsafe impl<T, A: Allocator> TrustedRandomAccessNoCoerce for IntoIter<T, A> where - T: Copy, + T: NonDrop, { const MAY_HAVE_SIDE_EFFECT: bool = false; } diff --git a/library/alloc/src/vec/source_iter_marker.rs b/library/alloc/src/vec/source_iter_marker.rs index e05788d99c0..6e78534cf5b 100644 --- a/library/alloc/src/vec/source_iter_marker.rs +++ b/library/alloc/src/vec/source_iter_marker.rs @@ -6,24 +6,14 @@ use super::{AsIntoIter, InPlaceDrop, SpecFromIter, SpecFromIterNested, Vec}; /// Specialization marker for collecting an iterator pipeline into a Vec while reusing the /// source allocation, i.e. executing the pipeline in place. -/// -/// The SourceIter parent trait is necessary for the specializing function to access the allocation -/// which is to be reused. But it is not sufficient for the specialization to be valid. See -/// additional bounds on the impl. #[rustc_unsafe_specialization_marker] -pub(super) trait SourceIterMarker: SourceIter<Source: AsIntoIter> {} +pub(super) trait InPlaceIterableMarker {} -// The std-internal SourceIter/InPlaceIterable traits are only implemented by chains of -// Adapter<Adapter<Adapter<IntoIter>>> (all owned by core/std). Additional bounds -// on the adapter implementations (beyond `impl<I: Trait> Trait for Adapter<I>`) only depend on other -// traits already marked as specialization traits (Copy, TrustedRandomAccess, FusedIterator). -// I.e. the marker does not depend on lifetimes of user-supplied types. Modulo the Copy hole, which -// several other specializations already depend on. -impl<T> SourceIterMarker for T where T: SourceIter<Source: AsIntoIter> + InPlaceIterable {} +impl<T> InPlaceIterableMarker for T where T: InPlaceIterable {} impl<T, I> SpecFromIter<T, I> for Vec<T> where - I: Iterator<Item = T> + SourceIterMarker, + I: Iterator<Item = T> + SourceIter<Source: AsIntoIter> + InPlaceIterableMarker, { default fn from_iter(mut iterator: I) -> Self { // Additional requirements which cannot expressed via trait bounds. We rely on const eval |
