2022-08-10 02:42:10 -05:00
const_eval_unstable_in_stable =
2022-06-28 23:26:05 -05:00
const-stable function cannot use `#[feature({$gate})]`
2022-08-10 02:42:10 -05:00
.unstable_sugg = if it is not part of the public API, make this function unstably const
.bypass_sugg = otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks
2022-06-28 23:46:01 -05:00
2022-08-10 02:42:10 -05:00
const_eval_thread_local_access =
2022-06-29 00:32:32 -05:00
thread-local statics cannot be accessed at compile-time
2022-08-10 02:42:10 -05:00
const_eval_static_access =
2022-07-07 22:46:18 -05:00
{$kind}s cannot refer to statics
2022-06-29 00:32:32 -05:00
.help = consider extracting the value of the `static` to a `const`, and referring to that
2022-08-10 02:42:10 -05:00
.teach_note = `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
.teach_help = To fix this, the value can be extracted to a `const` and then used.
2022-06-29 00:46:25 -05:00
2022-08-10 02:42:10 -05:00
const_eval_raw_ptr_to_int =
2022-06-29 00:46:25 -05:00
pointers cannot be cast to integers during const eval
.note = at compile-time, pointers do not have an integer value
.note2 = avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior
2022-08-10 02:42:10 -05:00
const_eval_raw_ptr_comparison =
2022-06-29 00:46:25 -05:00
pointers cannot be reliably compared during const eval
.note = see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
2022-08-10 02:42:10 -05:00
const_eval_panic_non_str = argument to `panic!()` in a const context must have type `&str`
2022-06-29 01:22:15 -05:00
2022-08-10 02:42:10 -05:00
const_eval_mut_deref =
2022-07-07 22:46:18 -05:00
mutation through a reference is not allowed in {$kind}s
2022-08-10 02:42:10 -05:00
const_eval_transient_mut_borrow = mutable references are not allowed in {$kind}s
2022-07-07 22:46:18 -05:00
2022-08-10 02:42:10 -05:00
const_eval_transient_mut_borrow_raw = raw mutable references are not allowed in {$kind}s
2022-08-17 23:54:11 -05:00
2022-08-22 10:14:49 -05:00
const_eval_max_num_nodes_in_const = maximum number of nodes exceeded in constant {$global_const_id}
2022-08-18 00:11:52 -05:00
2022-08-18 20:49:59 -05:00
const_eval_unallowed_fn_pointer_call = function pointer calls are not allowed in {$kind}s
2022-08-20 14:27:41 -05:00
const_eval_unstable_const_fn = `{$def_path}` is not yet stable as a const fn
2022-08-19 13:36:09 -05:00
const_eval_unallowed_mutable_refs =
mutable references are not allowed in the final value of {$kind}s
2022-08-22 10:38:16 -05:00
.teach_note =
2023-03-29 10:00:48 -05:00
References in statics and constants may only refer to immutable values.
2022-08-22 10:38:16 -05:00
Statics are shared everywhere, and if they refer to mutable data one might violate memory
2023-03-29 10:00:48 -05:00
safety since holding multiple mutable references to shared data is not allowed.
2022-08-19 13:36:09 -05:00
If you really want global mutable state, try using static mut or a global UnsafeCell.
const_eval_unallowed_mutable_refs_raw =
raw mutable references are not allowed in the final value of {$kind}s
2022-08-22 10:38:16 -05:00
.teach_note =
2023-03-29 10:00:48 -05:00
References in statics and constants may only refer to immutable values.
2022-08-22 10:38:16 -05:00
Statics are shared everywhere, and if they refer to mutable data one might violate memory
2023-03-29 10:00:48 -05:00
safety since holding multiple mutable references to shared data is not allowed.
2022-08-19 13:36:09 -05:00
If you really want global mutable state, try using static mut or a global UnsafeCell.
2022-08-22 10:38:16 -05:00
const_eval_non_const_fmt_macro_call =
2022-08-19 13:36:09 -05:00
cannot call non-const formatting macro in {$kind}s
2022-08-22 10:38:16 -05:00
const_eval_non_const_fn_call =
2022-08-19 13:36:09 -05:00
cannot call non-const fn `{$def_path_str}` in {$kind}s
2022-08-22 10:38:16 -05:00
const_eval_unallowed_op_in_const_context =
2022-08-19 13:36:09 -05:00
{$msg}
const_eval_unallowed_heap_allocations =
allocations are not allowed in {$kind}s
.label = allocation not allowed in {$kind}s
2022-08-22 10:38:16 -05:00
.teach_note =
2022-08-20 14:27:41 -05:00
The value of statics and constants must be known at compile time, and they live for the entire lifetime of a program. Creating a boxed value allocates memory on the heap at runtime, and therefore cannot be done at compile time.
2022-08-19 13:36:09 -05:00
const_eval_unallowed_inline_asm =
inline assembly is not allowed in {$kind}s
const_eval_interior_mutable_data_refer =
{$kind}s cannot refer to interior mutable data
.label = this borrow of an interior mutable value may end up in the final value
.help = to fix this, the value can be extracted to a separate `static` item and then referenced
2022-08-22 10:38:16 -05:00
.teach_note =
A constant containing interior mutable data behind a reference can allow you to modify that data.
This would make multiple uses of a constant to be able to see different values and allow circumventing
2022-08-19 13:36:09 -05:00
the `Send` and `Sync` requirements for shared mutable data, which is unsound.
2022-08-22 10:38:16 -05:00
const_eval_interior_mutability_borrow =
cannot borrow here, since the borrowed element may contain interior mutability