@@ -337,12 +337,12 @@ If a closure captures a field of a composite types such as structs, tuples, and
337
337
* Helper functions:
338
338
* ` unsafe_check(Place, Mode) -> (Place, Mode) `
339
339
* "Ensure unsafe accesses occur within the closure"
340
- * If Place contains a deref of a raw pointer:
341
- * Let Place1 = Place truncated just before the deref
342
- * Return (Place1, Mode )
343
- * If Mode is ` ref * ` and the place contains a field of a packed struct:
344
- * Let Place1 = Place truncated just before the field
345
- * Return (Place1, Mode )
340
+ * If Place contains a deref (at index ` i ` ) of a raw pointer:
341
+ * Let ` ( Place1, Mode1) = truncate_place( Place, Mode, i) `
342
+ * Return (Place1, Mode1 )
343
+ * If Mode is ` ref * ` and the place contains a field of a packed struct at index ` i ` :
344
+ * Let ` ( Place1, Mode1) = truncate_place( Place, Mode, i) `
345
+ * Return (Place1, Mode1 )
346
346
* Else
347
347
* Return (Place, Mode)
348
348
* ` move_xform(Place, Mode) -> (Place, Mode) ` (For move closures)
@@ -353,16 +353,16 @@ If a closure captures a field of a composite types such as structs, tuples, and
353
353
* Return (Place, Mode)
354
354
* Else if Mode is ` ref * ` and the place contains a deref of an ` & ` :
355
355
* Return (Place, Mode)
356
- * Else if place contains a deref:
357
- * Let Place1 = Place truncated just before the deref
356
+ * Else if place contains a deref at index ` i ` :
357
+ * Let ` ( Place1, _) = truncate_place( Place, Mode, i) `
358
358
* Return (Place1, ByValue)
359
359
* Else:
360
360
* Return (Place, ByValue)
361
361
* ` ref_xform(Place, Mode) -> (Place, Mode) ` (for ref closures)
362
362
* "If taking ownership of data, only move data from enclosing stack frame."
363
363
* Generate C' by mapping each (Mode, Place) in C
364
- * If Mode is ByValue and place contains a deref:
365
- * Let Place1 = Place truncated just before the deref
364
+ * If Mode is ByValue and place contains a deref at index ` i ` :
365
+ * Let ` ( Place1, _) = truncate_place( Place, Mode, i) `
366
366
* Return (Place1, ByValue)
367
367
* Else:
368
368
* Return (Place, Mode)
@@ -378,6 +378,13 @@ If a closure captures a field of a composite types such as structs, tuples, and
378
378
and ` Place.type_before_projection(l) = ty::Ref(.., Mutability::Not) `
379
379
* Let Place1 = (Base, Projections[ 0..=l] )
380
380
* Return (Place1, Ref)
381
+ * ` truncate_place(Place, Mode, len) -> (Place, Mode) `
382
+ * "Truncate the place to length ` len ` , i.e. upto but not including index ` len ` "
383
+ * "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"
384
+ * Let (Proj_before, Proj_after) = Place.split_before(len)
385
+ * 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 `
386
+ * Return (Place(Proj_before, ..InputPlace), ` ref-uniq ` )
387
+ * Else Return (Place(Proj_before, ..InputPlace), Mode)
381
388
382
389
## Key examples
383
390
0 commit comments