diff options
| author | Ralf Jung <post@ralfj.de> | 2025-06-18 10:04:43 +0900 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2025-06-26 18:11:24 +0200 |
| commit | bade3fd0580815f1a5a4abd33244982dc458d54d (patch) | |
| tree | 4e0ee736d00bcb324c517680895d5e6b9f771342 /compiler/rustc_const_eval/messages.ftl | |
| parent | ff17a225e6f0545d447546a12c520b932c9bcc88 (diff) | |
| download | rust-bade3fd0580815f1a5a4abd33244982dc458d54d.tar.gz rust-bade3fd0580815f1a5a4abd33244982dc458d54d.zip | |
clarify and unify 'transient mutable borrow' errors
Diffstat (limited to 'compiler/rustc_const_eval/messages.ftl')
| -rw-r--r-- | compiler/rustc_const_eval/messages.ftl | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/compiler/rustc_const_eval/messages.ftl b/compiler/rustc_const_eval/messages.ftl index 84b08a80cf0..97b154ad142 100644 --- a/compiler/rustc_const_eval/messages.ftl +++ b/compiler/rustc_const_eval/messages.ftl @@ -124,12 +124,13 @@ const_eval_incompatible_return_types = const_eval_incompatible_types = calling a function with argument of type {$callee_ty} passing data of type {$caller_ty} -const_eval_interior_mutable_ref_escaping = - {const_eval_const_context}s cannot refer to interior mutable data - .label = this borrow of an interior mutable value may end up in the final value +const_eval_interior_mutable_borrow_escaping = + interior mutable shared borrows of lifetime-extended temporaries in the top-level scope of a {const_eval_const_context} are not allowed + .label = this borrow of an interior mutable value refers to a lifetime-extended temporary .help = to fix this, the value can be extracted to a separate `static` item and then referenced .teach_note = - References that escape into the final value of a constant or static must be immutable. + This creates a raw pointer to a temporary that has its lifetime extended to last for the entire program. + Lifetime-extended temporaries in constants and statics must be immutable. This is to avoid accidentally creating shared mutable state. @@ -213,25 +214,17 @@ const_eval_memory_exhausted = const_eval_modified_global = modifying a static's initial value from another static's initializer -const_eval_mutable_ptr_in_final = encountered mutable pointer in final value of {const_eval_intern_kind} - -const_eval_mutable_raw_escaping = - raw mutable pointers are not allowed in the final value of {const_eval_const_context}s +const_eval_mutable_borrow_escaping = + mutable borrows of lifetime-extended temporaries in the top-level scope of a {const_eval_const_context} are not allowed .teach_note = - Pointers that escape into the final value of a constant or static must be immutable. + This creates a reference to a temporary that has its lifetime extended to last for the entire program. + Lifetime-extended temporaries in constants and statics must be immutable. This is to avoid accidentally creating shared mutable state. If you really want global mutable state, try using an interior mutable `static` or a `static mut`. -const_eval_mutable_ref_escaping = - mutable references are not allowed in the final value of {const_eval_const_context}s - .teach_note = - References that escape into the final value of a constant or static must be immutable. - This is to avoid accidentally creating shared mutable state. - - - If you really want global mutable state, try using an interior mutable `static` or a `static mut`. +const_eval_mutable_ptr_in_final = encountered mutable pointer in final value of {const_eval_intern_kind} const_eval_nested_static_in_thread_local = #[thread_local] does not support implicit nested statics, please create explicit static items and refer to them instead |
