You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rather than talking about lifetime-extended temporaries in the
top-level scope of an initializer, which is maybe a bit ambiguous,
let's speak directly to the result of the lifetime extension, which is
that these temporaries disallowed for borrows (in cases of interior
mutability) would have their lifetimes extended to the end of the
program.
operators used on integer and floating point types, `bool`, and `char`.
82
82
83
83
r[const-eval.const-expr.borrows]
84
-
* All forms of [borrow]s, including raw borrows, with one limitation:
85
-
mutable borrows and shared borrows to values with interior mutability
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].
84
+
* All forms of [borrow]s, including raw borrows, with one limitation: mutable borrows and shared borrows of expressions whose temporary scope would be extended (see [temporary lifetime extension]) to the end of the program are not allowed when those borrows refer to values with interior mutability.
In other words, they are only allowed to refer to *transient* places, to *indirect* places, or to *static* places.
115
-
A place is *transient* if it is based on a local variable whose lifetime is strictly contained inside the current [const context].
112
+
In other words, they are only allowed to refer to *transient* places, to *indirect* places, or to *static* places. A place is *transient* if it is based on a local variable whose lifetime is strictly contained inside the current [const context].
116
113
117
114
```rust
118
115
constC: () = {
@@ -260,7 +257,6 @@ of whether you are building on a `64` bit or a `32` bit system.
0 commit comments