@@ -14,10 +14,6 @@ pub(crate) enum Element<T> {
1414 /// epoch.
1515 Occupied ( Arc < T > , Epoch ) ,
1616
17- /// Like `Occupied`, but the resource has been marked as destroyed
18- /// and hasn't been dropped yet.
19- Destroyed ( Epoch ) ,
20-
2117 /// Like `Occupied`, but an error occurred when creating the
2218 /// resource.
2319 ///
7874 let ( index, epoch, _) = id. unzip ( ) ;
7975 match self . map . get ( index as usize ) {
8076 Some ( & Element :: Vacant ) => false ,
81- Some (
82- & Element :: Occupied ( _, storage_epoch)
83- | & Element :: Destroyed ( storage_epoch)
84- | & Element :: Error ( storage_epoch, _) ,
85- ) => storage_epoch == epoch,
77+ Some ( & Element :: Occupied ( _, storage_epoch) | & Element :: Error ( storage_epoch, _) ) => {
78+ storage_epoch == epoch
79+ }
8680 None => false ,
8781 }
8882 }
9993 let ( result, storage_epoch) = match self . map . get ( index as usize ) {
10094 Some ( & Element :: Occupied ( ref v, epoch) ) => ( Ok ( Some ( v) ) , epoch) ,
10195 Some ( & Element :: Vacant ) => return Ok ( None ) ,
102- Some ( & Element :: Error ( epoch, ..) ) | Some ( & Element :: Destroyed ( .., epoch) ) => {
103- ( Err ( InvalidId ) , epoch)
104- }
96+ Some ( & Element :: Error ( epoch, ..) ) => ( Err ( InvalidId ) , epoch) ,
10597 None => return Err ( InvalidId ) ,
10698 } ;
10799 assert_eq ! (
@@ -120,7 +112,6 @@ where
120112 Some ( & Element :: Occupied ( ref v, epoch) ) => ( Ok ( v) , epoch) ,
121113 Some ( & Element :: Vacant ) => panic ! ( "{}[{:?}] does not exist" , self . kind, id) ,
122114 Some ( & Element :: Error ( epoch, ..) ) => ( Err ( InvalidId ) , epoch) ,
123- Some ( & Element :: Destroyed ( .., epoch) ) => ( Err ( InvalidId ) , epoch) ,
124115 None => return Err ( InvalidId ) ,
125116 } ;
126117 assert_eq ! (
@@ -151,14 +142,6 @@ where
151142 }
152143 match std:: mem:: replace ( & mut self . map [ index] , element) {
153144 Element :: Vacant => { }
154- Element :: Destroyed ( storage_epoch) => {
155- assert_ne ! (
156- epoch,
157- storage_epoch,
158- "Index {index:?} of {} is already occupied" ,
159- T :: TYPE
160- ) ;
161- }
162145 Element :: Occupied ( _, storage_epoch) => {
163146 assert_ne ! (
164147 epoch,
@@ -209,22 +192,6 @@ where
209192 }
210193 }
211194
212- pub ( crate ) fn get_and_mark_destroyed ( & mut self , id : I ) -> Result < Arc < T > , InvalidId > {
213- let ( index, epoch, _) = id. unzip ( ) ;
214- let slot = & mut self . map [ index as usize ] ;
215- // borrowck dance: we have to move the element out before we can replace it
216- // with another variant with the same value.
217- if let & mut Element :: Occupied ( _, e) = slot {
218- if let Element :: Occupied ( value, storage_epoch) =
219- std:: mem:: replace ( slot, Element :: Destroyed ( e) )
220- {
221- debug_assert_eq ! ( storage_epoch, epoch) ;
222- return Ok ( value) ;
223- }
224- }
225- Err ( InvalidId )
226- }
227-
228195 pub ( crate ) fn force_replace ( & mut self , id : I , value : T ) {
229196 log:: trace!( "User is replacing {}{:?}" , T :: TYPE , id) ;
230197 let ( index, epoch, _) = id. unzip ( ) ;
@@ -239,10 +206,6 @@ where
239206 assert_eq ! ( epoch, storage_epoch) ;
240207 Some ( value)
241208 }
242- Element :: Destroyed ( storage_epoch) => {
243- assert_eq ! ( epoch, storage_epoch) ;
244- None
245- }
246209 Element :: Error ( ..) => None ,
247210 Element :: Vacant => panic ! ( "Cannot remove a vacant resource" ) ,
248211 }
0 commit comments