Skip to content

Commit 7712fe4

Browse files
committed
Add note about non-extension of array repeat operands
We document that the operands of an extending array expression are extending expressions, but `rustc` doesn't treat the repeat operand that way. Let's add a note about that flagging it as an open question and link to the relevant issue.
1 parent c367664 commit 7712fe4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/destructors.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,11 @@ are all extending expressions. The borrows in `&0 + &1` and `f(&mut 0)` are not.
444444
The operand of any extending borrow expression has its temporary scope
445445
extended.
446446

447+
> [!NOTE]
448+
> `rustc` does not treat [array repeat operands] of extending [array] expressions as extending expressions. Whether it should is an open question.
449+
>
450+
> For details, see [Rust issue #146092](https://github.com/rust-lang/rust/issues/146092).
451+
447452
#### Examples
448453

449454
Here are some examples where expressions have extended temporary scopes:
@@ -594,6 +599,7 @@ There is one additional case to be aware of: when a panic reaches a [non-unwindi
594599
[tuple variant]: type.enum.declaration
595600

596601
[array expression]: expressions/array-expr.md#array-expressions
602+
[array repeat operands]: expr.array.repeat-operand
597603
[async block expression]: expr.block.async
598604
[block expression]: expressions/block-expr.md
599605
[borrow expression]: expressions/operator-expr.md#borrow-operators

0 commit comments

Comments
 (0)