From ad0662363dd96a6320f714e4aec811dddb4ec64a Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Fri, 22 Nov 2024 05:46:00 +0800 Subject: [PATCH] rewording and make different cases for static and const eval context --- src/const_eval.md | 3 ++- src/items/constant-items.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/const_eval.md b/src/const_eval.md index 1b8031b5f..306c2afcf 100644 --- a/src/const_eval.md +++ b/src/const_eval.md @@ -43,7 +43,8 @@ r[const-eval.const-expr.path-item] r[const-eval.const-expr.path-static] * Paths to [statics] with these restrictions and observations. - * In particular, reads and writes to any `static mut` or [`extern` statics] is not allowed. + * If the evaluation is carried out in an initializer of a `const` item, or inside a `const` block, reads and writes to any `static mut` or [`extern` statics] are not allowed. + * If the evaluation is carried out in an initializer of a `static` item, reads into a `static`, or inside `unsafe` blocks reads into `static mut` are allowed. Reads and writes to `extern` statics are still not allowed. r[const-eval.const-expr.tuple] * [Tuple expressions]. diff --git a/src/items/constant-items.md b/src/items/constant-items.md index 770d08878..bb8a43827 100644 --- a/src/items/constant-items.md +++ b/src/items/constant-items.md @@ -48,6 +48,7 @@ const BITS_N_STRINGS: BitsNStrings<'static> = BitsNStrings { }; ``` +r[items.const.final-value-immutable] The final value of a `const` item cannot contain references to anything mutable. r[items.const.expr-omission]