Skip to content

Commit 62a33ad

Browse files
RalfJungtraviscross
authored andcommitted
also spell out which borrows are *not* allowed
1 parent 9d83c64 commit 62a33ad

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/const_eval.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ r[const-eval.const-expr.builtin-arith-logic]
8383
r[const-eval.const-expr.borrows]
8484
* All forms of [borrow]s, including raw borrows, with one limitation:
8585
mutable borrows and shared borrows to values with interior mutability
86-
are only allowed to refer to *transient* places, to *indirect* places, or to *static* places.
86+
are not allowed to refer to [lifetime-extended temporaries in the top-level scope of a `const` or `static` initializer expression][lifetime-extension-const].
87+
88+
In other words, they are only allowed to refer to *transient* places, to *indirect* places, or to *static* places.
8789
A place is *transient* if it is based on a local variable whose lifetime is strictly contained inside the current [const context].
8890
A place is *indirect* if it is based on a [dereference expression][dereference operator].
8991
A place is *static* if it is based on a `static` item or a [promoted expression].
@@ -188,6 +190,7 @@ of whether you are building on a `64` bit or a `32` bit system.
188190
[interior mutability]: interior-mutability.md
189191
[if]: expressions/if-expr.md#if-expressions
190192
[lazy boolean]: expressions/operator-expr.md#lazy-boolean-operators
193+
[lifetime-extension-const]: destructors.md#r-destructors.scope.lifetime-extension.static
191194
[let statements]: statements.md#let-statements
192195
[literals]: expressions/literal-expr.md
193196
[logical]: expressions/operator-expr.md#arithmetic-and-logical-binary-operators

0 commit comments

Comments
 (0)