diff options
| -rw-r--r-- | library/alloc/src/collections/binary_heap.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/vec/in_place_collect.rs | 9 | ||||
| -rw-r--r-- | library/alloc/src/vec/into_iter.rs | 12 | ||||
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 2 |
4 files changed, 14 insertions, 11 deletions
diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs index e6c3d38dab3..9849503f546 100644 --- a/library/alloc/src/collections/binary_heap.rs +++ b/library/alloc/src/collections/binary_heap.rs @@ -1416,7 +1416,7 @@ unsafe impl<T> SourceIter for IntoIter<T> { #[doc(hidden)] unsafe impl<I> InPlaceIterable for IntoIter<I> {} -impl<I> AsIntoIter for IntoIter<I> { +unsafe impl<I> AsIntoIter for IntoIter<I> { type Item = I; fn as_into_iter(&mut self) -> &mut vec::IntoIter<Self::Item> { diff --git a/library/alloc/src/vec/in_place_collect.rs b/library/alloc/src/vec/in_place_collect.rs index 6e78534cf5b..ff7780ee07d 100644 --- a/library/alloc/src/vec/in_place_collect.rs +++ b/library/alloc/src/vec/in_place_collect.rs @@ -2,7 +2,7 @@ use core::iter::{InPlaceIterable, SourceIter, TrustedRandomAccessNoCoerce}; use core::mem::{self, ManuallyDrop}; use core::ptr::{self}; -use super::{AsIntoIter, InPlaceDrop, SpecFromIter, SpecFromIterNested, Vec}; +use super::{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. @@ -154,3 +154,10 @@ where len } } + +// internal helper trait for in-place iteration specialization. +#[rustc_specialization_trait] +pub(crate) unsafe trait AsIntoIter { + type Item; + fn as_into_iter(&mut self) -> &mut super::IntoIter<Self::Item>; +} diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index f985fb78465..7cbf3395269 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -1,3 +1,5 @@ +#[cfg(not(no_global_oom_handling))] +use super::AsIntoIter; use crate::alloc::{Allocator, Global}; use crate::raw_vec::RawVec; use core::fmt; @@ -338,14 +340,8 @@ unsafe impl<T, A: Allocator> SourceIter for IntoIter<T, A> { } } -// internal helper trait for in-place iteration specialization. -#[rustc_specialization_trait] -pub(crate) trait AsIntoIter { - type Item; - fn as_into_iter(&mut self) -> &mut IntoIter<Self::Item>; -} - -impl<T> AsIntoIter for IntoIter<T> { +#[cfg(not(no_global_oom_handling))] +unsafe impl<T> AsIntoIter for IntoIter<T> { type Item = T; fn as_into_iter(&mut self) -> &mut IntoIter<Self::Item> { diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 07d109ea8e1..0b305b49d51 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -96,7 +96,7 @@ mod drain; mod cow; #[cfg(not(no_global_oom_handling))] -pub(crate) use self::into_iter::AsIntoIter; +pub(crate) use self::in_place_collect::AsIntoIter; #[stable(feature = "rust1", since = "1.0.0")] pub use self::into_iter::IntoIter; |
