@@ -167,13 +167,15 @@ impl<'tcx> Stack {
167167 behind a barrier", bor) )
168168 }
169169 ( BorStackItem :: Uniq ( itm_t) , Borrow :: Uniq ( bor_t) ) if itm_t == bor_t => {
170- // Found matching unique item.
170+ // Found matching unique item. This is *always* required to use a `Uniq`:
171+ // The item must still be on the stack.
171172 if !is_write {
172- // As a special case, if we are reading and since we *did* find the `Uniq`,
173- // we try to pop less: We are happy with making a `Shr` or `Frz` active;
174- // that one will not mind concurrent reads.
173+ // As a special case, if we are reading, let us see if it would be
174+ // beneficial to pretend we are a raw pointer instead. If
175+ // raw pointers are allowed to read while popping *less* than we
176+ // would have to pop, there is no reason not to let them do this.
175177 match self . reactivatable ( Borrow :: default ( ) , is_write) {
176- // If we got something better that `idx`, use that
178+ // If we got something better (popping less) that `idx`, use that
177179 Ok ( None ) => return Ok ( None ) ,
178180 Ok ( Some ( shr_idx) ) if shr_idx <= idx => return Ok ( Some ( shr_idx) ) ,
179181 // Otherwise just go on.
@@ -329,6 +331,8 @@ impl<'tcx> Stacks {
329331 ) ) )
330332 }
331333 // Sometimes we also need to be frozen.
334+ // In this case we *both* push `Shr` and then freeze. This means that a `&mut`
335+ // to `*const` to `*mut` cast through `&` actually works.
332336 if frozen {
333337 // Even shared refs can have uniq tags (after transmute). That's not an error
334338 // but they do not get any freezing benefits.
0 commit comments