@@ -351,12 +351,12 @@ If a closure captures a field of a composite types such as structs, tuples, and
351
351
* Helper functions:
352
352
* ` unsafe_check(Place, Mode) -> (Place, Mode) `
353
353
* "Ensure unsafe accesses occur within the closure"
354
- * If Place contains a deref of a raw pointer:
355
- * Let Place1 = Place truncated just before the deref
356
- * Return (Place1, Mode )
357
- * If Mode is ` ref * ` and the place contains a field of a packed struct:
358
- * Let Place1 = Place truncated just before the field
359
- * Return (Place1, Mode )
354
+ * If Place contains a deref (at index ` i ` ) of a raw pointer:
355
+ * Let ` ( Place1, Mode1) = truncate_place( Place, Mode, i) `
356
+ * Return (Place1, Mode1 )
357
+ * If Mode is ` ref * ` and the place contains a field of a packed struct at index ` i ` :
358
+ * Let ` ( Place1, Mode1) = truncate_place( Place, Mode, i) `
359
+ * Return (Place1, Mode1 )
360
360
* Else
361
361
* Return (Place, Mode)
362
362
* ` move_xform(Place, Mode) -> (Place, Mode) ` (For move closures)
@@ -367,16 +367,16 @@ If a closure captures a field of a composite types such as structs, tuples, and
367
367
* Return (Place, Mode)
368
368
* Else if Mode is ` ref * ` and the place contains a deref of an ` & ` :
369
369
* Return (Place, Mode)
370
- * Else if place contains a deref:
371
- * Let Place1 = Place truncated just before the deref
370
+ * Else if place contains a deref at index ` i ` :
371
+ * Let ` ( Place1, _) = truncate_place( Place, Mode, i) `
372
372
* Return (Place1, ByValue)
373
373
* Else:
374
374
* Return (Place, ByValue)
375
375
* ` ref_xform(Place, Mode) -> (Place, Mode) ` (for ref closures)
376
376
* "If taking ownership of data, only move data from enclosing stack frame."
377
377
* Generate C' by mapping each (Mode, Place) in C
378
- * If Mode is ByValue and place contains a deref:
379
- * Let Place1 = Place truncated just before the deref
378
+ * If Mode is ByValue and place contains a deref at index ` i ` :
379
+ * Let ` ( Place1, _) = truncate_place( Place, Mode, i) `
380
380
* Return (Place1, ByValue)
381
381
* Else:
382
382
* Return (Place, Mode)
@@ -392,6 +392,13 @@ If a closure captures a field of a composite types such as structs, tuples, and
392
392
and ` Place.type_before_projection(l) = ty::Ref(.., Mutability::Not) `
393
393
* Let Place1 = (Base, Projections[ 0..=l] )
394
394
* Return (Place1, Ref)
395
+ * ` truncate_place(Place, Mode, len) -> (Place, Mode) `
396
+ * "Truncate the place to length ` len ` , i.e. upto but not including index ` len ` "
397
+ * "If during truncation we drop Deref of a ` &mut ` and the place was being used by ` ref mut ` , the access to the truncated place must be unique"
398
+ * Let (Proj_before, Proj_after) = Place.split_before(len)
399
+ * If Mode == ` ref mut ` and there exists ` Deref ` in ` Proj_after ` at index ` i ` such that ` Place.type_before_projection(len + i) ` is ` &mut T `
400
+ * Return (Place(Proj_before, ..InputPlace), ` ref-uniq ` )
401
+ * Else Return (Place(Proj_before, ..InputPlace), Mode)
395
402
396
403
## Key examples
397
404
0 commit comments