@@ -139,13 +139,13 @@ pub struct Stacks {
139
139
/// Core operations
140
140
impl < ' tcx > Stack {
141
141
/// 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).
144
144
/// Returns `Err` if the answer is "no"; otherwise the return value indicates what to
145
145
/// 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 > {
147
147
// Check if we can match the frozen "item". Not possible on writes!
148
- if usage != UsageKind :: Write {
148
+ if !is_write {
149
149
// For now, we do NOT check the timestamp. That might be surprising, but
150
150
// we cannot even notice when a location should be frozen but is not!
151
151
// Those checks are both done in `tag_dereference`, where we have type information.
@@ -168,11 +168,11 @@ impl<'tcx> Stack {
168
168
}
169
169
( BorStackItem :: Uniq ( itm_t) , Borrow :: Uniq ( bor_t) ) if itm_t == bor_t => {
170
170
// Found matching unique item.
171
- if usage == UsageKind :: Read {
171
+ if !is_write {
172
172
// As a special case, if we are reading and since we *did* find the `Uniq`,
173
173
// we try to pop less: We are happy with making a `Shr` or `Frz` active;
174
174
// that one will not mind concurrent reads.
175
- match self . reactivatable ( Borrow :: default ( ) , usage ) {
175
+ match self . reactivatable ( Borrow :: default ( ) , is_write ) {
176
176
// If we got something better that `idx`, use that
177
177
Ok ( None ) => return Ok ( None ) ,
178
178
Ok ( Some ( shr_idx) ) if shr_idx <= idx => return Ok ( Some ( shr_idx) ) ,
@@ -194,10 +194,10 @@ impl<'tcx> Stack {
194
194
Err ( format ! ( "Borrow-to-reactivate {:?} does not exist on the stack" , bor) )
195
195
}
196
196
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 ) {
201
201
Ok ( None ) => return Ok ( ( ) ) ,
202
202
Ok ( Some ( pop) ) => pop,
203
203
Err ( err) => return err ! ( MachineError ( err) ) ,
@@ -272,7 +272,7 @@ impl State {
272
272
273
273
/// Higher-level operations
274
274
impl < ' 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,
276
276
/// and if `new_bor` is present then make that the new current borrow.
277
277
fn use_and_maybe_re_borrow (
278
278
& self ,
@@ -285,7 +285,7 @@ impl<'tcx> Stacks {
285
285
ptr. tag, usage, new_bor, ptr, size. bytes( ) ) ;
286
286
let mut stacks = self . stacks . borrow_mut ( ) ;
287
287
for stack in stacks. iter_mut ( ptr. offset , size) {
288
- stack. reactivate ( ptr. tag , usage) ?;
288
+ stack. reactivate ( ptr. tag , usage == UsageKind :: Write ) ?;
289
289
if let Some ( new_bor) = new_bor {
290
290
stack. initiate ( new_bor) ;
291
291
}
@@ -317,7 +317,7 @@ impl<'tcx> Stacks {
317
317
// We need `iter_mut` because `iter` would skip gaps!
318
318
for stack in stacks. iter_mut ( ptr. offset , size) {
319
319
// 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 ) {
321
321
return err ! ( MachineError ( format!(
322
322
"Encountered reference with non-reactivatable tag: {}" ,
323
323
err
0 commit comments