Skip to content

Commit e5ff66d

Browse files
committed
specify lifetime extension of match arms and if tail expressions
1 parent 0a25dea commit e5ff66d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/destructors.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,8 @@ expression which is one of the following:
435435
expression.
436436
* The arguments to an extending [tuple struct] or [tuple variant] constructor expression.
437437
* The final expression of any extending [block expression].
438+
* The arm(s) of an extending [`match`] expression.
439+
* The final expressions of an extending [`if`] expression's consequent, `else if`, and `else` blocks.
438440

439441
So the borrow expressions in `&mut 0`, `(&1, &mut 2)`, and `Some(&mut 3)`
440442
are all extending expressions. The borrows in `&0 + &1` and `f(&mut 0)` are not.
@@ -458,6 +460,10 @@ let x = (&*&temp(),);
458460
# x;
459461
let x = { [Some(&temp()) ] };
460462
# x;
463+
let x = match () { _ => &temp() };
464+
# x;
465+
let x = if true { &temp() } else { &temp() };
466+
# x;
461467
let ref x = temp();
462468
# x;
463469
let ref x = *&temp();
@@ -477,6 +483,8 @@ let x = std::convert::identity(&temp()); // ERROR
477483
# x;
478484
let x = (&temp()).use_temp(); // ERROR
479485
# x;
486+
let x = match &temp() { x => x }; // ERROR
487+
# x;
480488
```
481489

482490
r[destructors.forget]

0 commit comments

Comments
 (0)