@@ -375,48 +375,14 @@ Formally, we define a predicate `LIFETIME(LV, LT, MQ)`, which states that
375
375
` MQ ` ". The Rust code corresponding to this predicate is the module
376
376
` middle::borrowck::gather_loans::lifetime ` .
377
377
378
- ### The Scope function
379
-
380
- Several of the rules refer to a helper function ` SCOPE(LV)=LT ` . The
381
- ` SCOPE(LV) ` yields the lifetime ` LT ` for which the lvalue ` LV ` is
382
- guaranteed to exist, presuming that no mutations occur.
383
-
384
- The scope of a local variable is the block where it is declared:
385
-
386
- ``` text
387
- SCOPE(X) = block where X is declared
388
- ```
389
-
390
- The scope of a field is the scope of the struct:
391
-
392
- ``` text
393
- SCOPE(LV.f) = SCOPE(LV)
394
- ```
395
-
396
- The scope of a unique referent is the scope of the pointer, since
397
- (barring mutation or moves) the pointer will not be freed until
398
- the pointer itself ` LV ` goes out of scope:
399
-
400
- ``` text
401
- SCOPE(*LV) = SCOPE(LV) if LV has type Box<T>
402
- ```
403
-
404
- The scope of a borrowed referent is the scope associated with the
405
- pointer. This is a conservative approximation, since the data that
406
- the pointer points at may actually live longer:
407
-
408
- ``` text
409
- SCOPE(*LV) = LT if LV has type &'LT T or &'LT mut T
410
- ```
411
-
412
378
### Checking lifetime of variables
413
379
414
380
The rule for variables states that a variable can only be borrowed a
415
381
lifetime ` LT ` that is a subregion of the variable's scope:
416
382
417
383
``` text
418
384
LIFETIME(X, LT, MQ) // L-Local
419
- LT <= SCOPE(X)
385
+ LT <= block where X is declared
420
386
```
421
387
422
388
### Checking lifetime for owned content
0 commit comments