File tree Expand file tree Collapse file tree
compiler/rustc_data_structures/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,8 +67,13 @@ impl<V: FlatMapInPlaceVec> FlatMapInPlace<V::Elem> for V {
6767 }
6868}
6969
70- // A vec-like type must implement these operations to support `flat_map_in_place`.
71- pub trait FlatMapInPlaceVec {
70+ /// A vec-like type must implement these operations to support `flat_map_in_place`.
71+ ///
72+ /// # Safety
73+ ///
74+ /// The memory safety of the unsafe block in `flat_map_in_place` relies on impls of this trait
75+ /// implementing all the operations correctly.
76+ pub unsafe trait FlatMapInPlaceVec {
7277 type Elem ;
7378
7479 fn len ( & self ) -> usize ;
@@ -78,7 +83,7 @@ pub trait FlatMapInPlaceVec {
7883 fn insert ( & mut self , idx : usize , elem : Self :: Elem ) ;
7984}
8085
81- impl < T > FlatMapInPlaceVec for Vec < T > {
86+ unsafe impl < T > FlatMapInPlaceVec for Vec < T > {
8287 type Elem = T ;
8388
8489 fn len ( & self ) -> usize {
@@ -104,7 +109,7 @@ impl<T> FlatMapInPlaceVec for Vec<T> {
104109 }
105110}
106111
107- impl < T > FlatMapInPlaceVec for ThinVec < T > {
112+ unsafe impl < T > FlatMapInPlaceVec for ThinVec < T > {
108113 type Elem = T ;
109114
110115 fn len ( & self ) -> usize {
@@ -130,7 +135,7 @@ impl<T> FlatMapInPlaceVec for ThinVec<T> {
130135 }
131136}
132137
133- impl < T , const N : usize > FlatMapInPlaceVec for SmallVec < [ T ; N ] > {
138+ unsafe impl < T , const N : usize > FlatMapInPlaceVec for SmallVec < [ T ; N ] > {
134139 type Elem = T ;
135140
136141 fn len ( & self ) -> usize {
You can’t perform that action at this time.
0 commit comments