Skip to content

Commit d1d26a5

Browse files
committed
move AsIntoIter helper trait and mark it as unsafe
1 parent bfc8a63 commit d1d26a5

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

alloc/src/collections/binary_heap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ unsafe impl<T> SourceIter for IntoIter<T> {
14161416
#[doc(hidden)]
14171417
unsafe impl<I> InPlaceIterable for IntoIter<I> {}
14181418

1419-
impl<I> AsIntoIter for IntoIter<I> {
1419+
unsafe impl<I> AsIntoIter for IntoIter<I> {
14201420
type Item = I;
14211421

14221422
fn as_into_iter(&mut self) -> &mut vec::IntoIter<Self::Item> {

alloc/src/vec/in_place_collect.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use core::iter::{InPlaceIterable, SourceIter, TrustedRandomAccessNoCoerce};
22
use core::mem::{self, ManuallyDrop};
33
use core::ptr::{self};
44

5-
use super::{AsIntoIter, InPlaceDrop, SpecFromIter, SpecFromIterNested, Vec};
5+
use super::{InPlaceDrop, SpecFromIter, SpecFromIterNested, Vec};
66

77
/// Specialization marker for collecting an iterator pipeline into a Vec while reusing the
88
/// source allocation, i.e. executing the pipeline in place.
@@ -154,3 +154,10 @@ where
154154
len
155155
}
156156
}
157+
158+
// internal helper trait for in-place iteration specialization.
159+
#[rustc_specialization_trait]
160+
pub(crate) unsafe trait AsIntoIter {
161+
type Item;
162+
fn as_into_iter(&mut self) -> &mut super::IntoIter<Self::Item>;
163+
}

alloc/src/vec/into_iter.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#[cfg(not(no_global_oom_handling))]
2+
use super::AsIntoIter;
13
use crate::alloc::{Allocator, Global};
24
use crate::raw_vec::RawVec;
35
use core::fmt;
@@ -338,14 +340,8 @@ unsafe impl<T, A: Allocator> SourceIter for IntoIter<T, A> {
338340
}
339341
}
340342

341-
// internal helper trait for in-place iteration specialization.
342-
#[rustc_specialization_trait]
343-
pub(crate) trait AsIntoIter {
344-
type Item;
345-
fn as_into_iter(&mut self) -> &mut IntoIter<Self::Item>;
346-
}
347-
348-
impl<T> AsIntoIter for IntoIter<T> {
343+
#[cfg(not(no_global_oom_handling))]
344+
unsafe impl<T> AsIntoIter for IntoIter<T> {
349345
type Item = T;
350346

351347
fn as_into_iter(&mut self) -> &mut IntoIter<Self::Item> {

alloc/src/vec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ mod drain;
9696
mod cow;
9797

9898
#[cfg(not(no_global_oom_handling))]
99-
pub(crate) use self::into_iter::AsIntoIter;
99+
pub(crate) use self::in_place_collect::AsIntoIter;
100100
#[stable(feature = "rust1", since = "1.0.0")]
101101
pub use self::into_iter::IntoIter;
102102

0 commit comments

Comments
 (0)