Skip to content

Commit 0836680

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

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
@@ -382,11 +382,11 @@ expression which is one of the following:
382382
* The operand(s) of an extending [array][array expression], [cast][cast
383383
expression], [braced struct][struct expression], or [tuple][tuple expression]
384384
expression.
385+
* The arguments to an extending [tuple struct] or [tuple variant] constructor expression.
385386
* The final expression of any extending [block expression].
386387

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

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

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

0 commit comments

Comments
 (0)