@@ -139,13 +139,13 @@ pub struct Stacks {
139139/// Core operations
140140impl < ' tcx > Stack {
141141 /// Check if `bor` could be activated by unfreezing and popping.
142- /// `usage ` indicates whether this is being used to read/ write (or, equivalently, to
143- /// borrow as &/& mut), or to borrow as raw .
142+ /// `is_write ` indicates whether this is being used to write (or, equivalently, to
143+ /// borrow as &mut).
144144 /// Returns `Err` if the answer is "no"; otherwise the return value indicates what to
145145 /// do: With `Some(n)` you need to unfreeze, and then additionally pop `n` items.
146- fn reactivatable ( & self , bor : Borrow , usage : UsageKind ) -> Result < Option < usize > , String > {
146+ fn reactivatable ( & self , bor : Borrow , is_write : bool ) -> Result < Option < usize > , String > {
147147 // Check if we can match the frozen "item". Not possible on writes!
148- if usage != UsageKind :: Write {
148+ if !is_write {
149149 // For now, we do NOT check the timestamp. That might be surprising, but
150150 // we cannot even notice when a location should be frozen but is not!
151151 // Those checks are both done in `tag_dereference`, where we have type information.
@@ -168,11 +168,11 @@ impl<'tcx> Stack {
168168 }
169169 ( BorStackItem :: Uniq ( itm_t) , Borrow :: Uniq ( bor_t) ) if itm_t == bor_t => {
170170 // Found matching unique item.
171- if usage == UsageKind :: Read {
171+ if !is_write {
172172 // As a special case, if we are reading and since we *did* find the `Uniq`,
173173 // we try to pop less: We are happy with making a `Shr` or `Frz` active;
174174 // that one will not mind concurrent reads.
175- match self . reactivatable ( Borrow :: default ( ) , usage ) {
175+ match self . reactivatable ( Borrow :: default ( ) , is_write ) {
176176 // If we got something better that `idx`, use that
177177 Ok ( None ) => return Ok ( None ) ,
178178 Ok ( Some ( shr_idx) ) if shr_idx <= idx => return Ok ( Some ( shr_idx) ) ,
@@ -194,10 +194,10 @@ impl<'tcx> Stack {
194194 Err ( format ! ( "Borrow-to-reactivate {:?} does not exist on the stack" , bor) )
195195 }
196196
197- /// Reactive `bor` for this stack. `usage ` indicates whether this is being
198- /// used to read/ write (or, equivalently, to borrow as &/& mut), or to borrow as raw .
199- fn reactivate ( & mut self , bor : Borrow , usage : UsageKind ) -> EvalResult < ' tcx > {
200- let mut pop = match self . reactivatable ( bor, usage ) {
197+ /// Reactive `bor` for this stack. `is_write ` indicates whether this is being
198+ /// used to write (or, equivalently, to borrow as &mut).
199+ fn reactivate ( & mut self , bor : Borrow , is_write : bool ) -> EvalResult < ' tcx > {
200+ let mut pop = match self . reactivatable ( bor, is_write ) {
201201 Ok ( None ) => return Ok ( ( ) ) ,
202202 Ok ( Some ( pop) ) => pop,
203203 Err ( err) => return err ! ( MachineError ( err) ) ,
@@ -272,7 +272,7 @@ impl State {
272272
273273/// Higher-level operations
274274impl < ' tcx > Stacks {
275- /// The single most important operation: Make sure that using `ptr` as `usage` is okay,
275+ /// The single most important operation: Make sure that using `ptr` is okay,
276276 /// and if `new_bor` is present then make that the new current borrow.
277277 fn use_and_maybe_re_borrow (
278278 & self ,
@@ -285,7 +285,7 @@ impl<'tcx> Stacks {
285285 ptr. tag, usage, new_bor, ptr, size. bytes( ) ) ;
286286 let mut stacks = self . stacks . borrow_mut ( ) ;
287287 for stack in stacks. iter_mut ( ptr. offset , size) {
288- stack. reactivate ( ptr. tag , usage) ?;
288+ stack. reactivate ( ptr. tag , usage == UsageKind :: Write ) ?;
289289 if let Some ( new_bor) = new_bor {
290290 stack. initiate ( new_bor) ;
291291 }
@@ -317,7 +317,7 @@ impl<'tcx> Stacks {
317317 // We need `iter_mut` because `iter` would skip gaps!
318318 for stack in stacks. iter_mut ( ptr. offset , size) {
319319 // Conservatively assume we will just read
320- if let Err ( err) = stack. reactivatable ( ptr. tag , UsageKind :: Read ) {
320+ if let Err ( err) = stack. reactivatable ( ptr. tag , /*is_write*/ false ) {
321321 return err ! ( MachineError ( format!(
322322 "Encountered reference with non-reactivatable tag: {}" ,
323323 err
0 commit comments