From 1bacab13992cc32b956eb98fc3ba4b2f202d2492 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 27 Aug 2024 21:07:09 +0200 Subject: [PATCH 1/2] const_eval: update for const_mut_refs and const_refs_to_cell stabilization --- src/const_eval.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/const_eval.md b/src/const_eval.md index e3cefa5c7..dfcb61b07 100644 --- a/src/const_eval.md +++ b/src/const_eval.md @@ -38,8 +38,11 @@ to be run. * [Closure expressions] which don't capture variables from the environment. * Built-in [negation], [arithmetic], [logical], [comparison] or [lazy boolean] operators used on integer and floating point types, `bool`, and `char`. -* Shared [borrow]s, except if applied to a type with [interior mutability]. -* The [dereference operator] except for raw pointers. +* All forms of [borrow]s, including raw borrows, with one limitation: + mutable borrows and shared borrows to values with interior mutability + are only allowed to refer to *transient* places. A place is *transient* + if it will be deallocated before the end of evaluating the current constant item. +* The [dereference operator]. * [Grouped] expressions. * [Cast] expressions, except * pointer to address casts and From ace105a62d42374682b2dc2b6f63a1aa6814ba91 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 28 Aug 2024 07:39:33 +0200 Subject: [PATCH 2/2] talk about const contexts, not const items --- src/const_eval.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/const_eval.md b/src/const_eval.md index dfcb61b07..eca2530ea 100644 --- a/src/const_eval.md +++ b/src/const_eval.md @@ -41,7 +41,7 @@ to be run. * All forms of [borrow]s, including raw borrows, with one limitation: mutable borrows and shared borrows to values with interior mutability are only allowed to refer to *transient* places. A place is *transient* - if it will be deallocated before the end of evaluating the current constant item. + if its lifetime is strictly contained inside the current [const context]. * The [dereference operator]. * [Grouped] expressions. * [Cast] expressions, except @@ -52,6 +52,7 @@ to be run. * [if], [`if let`] and [match] expressions. ## Const context +[const context]: #const-context A _const context_ is one of the following: