Skip to content

Commit 8cdf7dd

Browse files
committed
Extremely rough draft: remove sub-expressions ambiguity
1 parent 084b888 commit 8cdf7dd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/destructors.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,15 @@ println!("{}", x);
386386
```
387387

388388
r[destructors.scope.lifetime-extension.sub-expressions]
389-
If a [borrow], [dereference][dereference expression], [field][field expression], or [tuple indexing expression] has an extended temporary scope, then so does its operand. If an [indexing expression] has an extended temporary scope, then the indexed expression also has an extended temporary scope.
389+
A *place base context* is an expression context that is one of the following:
390+
391+
- The operand of a [dereference][dereference expression], [field][field expression], or [tuple indexing expression].
392+
- The indexed expression of an [indexing expression].
393+
- The operand of a [borrow expression] in a place base context.
394+
395+
The *projected expression* of an expression in a place base context is its closest ancestor that is not in a place base context.
396+
397+
The temporary scope of an expression in a place base context is defined to be the temporary scope of its projected expression.
390398

391399
```rust
392400
# use core::sync::atomic::{AtomicU64, Ordering::Relaxed};
@@ -477,15 +485,15 @@ r[destructors.scope.lifetime-extension.exprs]
477485
#### Extending based on expressions
478486

479487
r[destructors.scope.lifetime-extension.exprs.borrows]
480-
The [temporary scope] of the operand of a [borrow] expression is the *borrow scope* of the operand expression, defined below.
488+
The [temporary scope] of the operand of a [borrow expression] outside of a [place base context][destructors.scope.lifetime-extension.sub-expressions] is the *borrow scope* of the operand expression, defined below.
481489

482490
r[destructors.scope.lifetime-extension.exprs.super-macros]
483491
The [scope][temporary scope] of each [super temporary] of a [super macro call] expression is the borrow scope of the super macro call expression.
484492

485493
r[destructors.scope.lifetime-extension.exprs.extending]
486494
The borrow scope of an expression is defined in terms of *extending expressions* and their *extending parents*. An extending expression is an expression which is one of the following:
487495

488-
* The operand of a [borrow] expression, the extending parent of which is the borrow expression.
496+
* The operand of a [borrow expression], the extending parent of which is the borrow expression.
489497
* The [super operands] of a [super macro call] expression, the extending parent of which is the macro call expression.
490498
* The operand(s) of an [array][array expression], [cast][cast
491499
expression], [braced struct][struct expression], or [tuple][tuple expression]
@@ -733,7 +741,7 @@ There is one additional case to be aware of: when a panic reaches a [non-unwindi
733741
[array expression]: expressions/array-expr.md#array-expressions
734742
[array repeat operands]: expr.array.repeat-operand
735743
[block expression]: expressions/block-expr.md
736-
[borrow]: expr.operator.borrow
744+
[borrow expression]: expr.operator.borrow
737745
[cast expression]: expressions/operator-expr.md#type-cast-expressions
738746
[const block expression]: expr.block.const
739747
[dereference expression]: expressions/operator-expr.md#the-dereference-operator

0 commit comments

Comments
 (0)