Skip to content

Commit b52d5d2

Browse files
m-ou-seehuss
authored andcommitted
Update reference for rust-lang/rust#140593
1 parent fb58c5d commit b52d5d2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/destructors.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,11 @@ expression which is one of the following:
383383
* The operand(s) of an extending [array][array expression], [cast][cast
384384
expression], [braced struct][struct expression], or [tuple][tuple expression]
385385
expression.
386+
* The arguments to an extending [tuple struct] or [tuple variant] constructor expression.
386387
* The final expression of any extending [block expression].
387388

388-
So the borrow expressions in `&mut 0`, `(&1, &mut 2)`, and `Some { 0: &mut 3 }`
389-
are all extending expressions. The borrows in `&0 + &1` and `Some(&mut 0)` are
390-
not: the latter is syntactically a function call expression.
389+
So the borrow expressions in `&mut 0`, `(&1, &mut 2)`, and `Some(&mut 3)`
390+
are all extending expressions. The borrows in `&0 + &1` and `f(&mut 0)` are not.
391391

392392
The operand of any extending borrow expression has its temporary scope
393393
extended.
@@ -405,7 +405,7 @@ Here are some examples where expressions have extended temporary scopes:
405405
let x = &temp();
406406
let x = &temp() as &dyn Send;
407407
let x = (&*&temp(),);
408-
let x = { [Some { 0: &temp(), }] };
408+
let x = { [Some(&temp()) ] };
409409
let ref x = temp();
410410
let ref x = *&temp();
411411
# x;
@@ -420,7 +420,7 @@ Here are some examples where expressions don't have extended temporary scopes:
420420
// The temporary that stores the result of `temp()` only lives until the
421421
// end of the let statement in these cases.
422422
423-
let x = Some(&temp()); // ERROR
423+
let x = std::convert::identity(&temp()); // ERROR
424424
let x = (&temp()).use_temp(); // ERROR
425425
# x;
426426
```
@@ -477,6 +477,8 @@ There is one additional case to be aware of: when a panic reaches a [non-unwindi
477477
[struct pattern]: patterns.md#struct-patterns
478478
[tuple pattern]: patterns.md#tuple-patterns
479479
[tuple struct pattern]: patterns.md#tuple-struct-patterns
480+
[tuple struct]: type.struct.tuple
481+
[tuple variant]: type.enum.declaration
480482

481483
[array expression]: expressions/array-expr.md#array-expressions
482484
[block expression]: expressions/block-expr.md

0 commit comments

Comments
 (0)