Skip to content

Commit 6464586

Browse files
committed
add explanation to specialization marker
1 parent acdd441 commit 6464586

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

library/alloc/src/vec.rs

+6
Original file line numberDiff line numberDiff line change
@@ -2227,6 +2227,12 @@ fn write_in_place_with_drop<T>(
22272227
#[rustc_unsafe_specialization_marker]
22282228
trait SourceIterMarker: SourceIter<Source: AsIntoIter> {}
22292229

2230+
// The std-internal SourceIter/InPlaceIterable traits are only implemented by chains of
2231+
// Adapter<Adapter<Adapter<IntoIter>>> (all owned by core/std). Additional bounds
2232+
// on the adapter implementations (beyond `impl<I: Trait> Trait for Adapter<I>`) only depend on other
2233+
// traits already marked as specialization traits (Copy, TrustedRandomAccess, FusedIterator).
2234+
// I.e. the marker does not depend on lifetimes of user-supplied types. Modulo the Copy hole, which
2235+
// several other specializations already depend on.
22302236
impl<T> SourceIterMarker for T where T: SourceIter<Source: AsIntoIter> + InPlaceIterable {}
22312237

22322238
impl<T, I> SpecFrom<T, I> for Vec<T>

0 commit comments

Comments
 (0)