]>
Commit | Line | Data |
---|---|---|
f2b60f7d | 1 | const_eval_unstable_in_stable = |
064997fb | 2 | const-stable function cannot use `#[feature({$gate})]` |
f2b60f7d FG |
3 | .unstable_sugg = if it is not part of the public API, make this function unstably const |
4 | .bypass_sugg = otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks | |
064997fb | 5 | |
f2b60f7d | 6 | const_eval_thread_local_access = |
064997fb FG |
7 | thread-local statics cannot be accessed at compile-time |
8 | ||
f2b60f7d | 9 | const_eval_static_access = |
064997fb FG |
10 | {$kind}s cannot refer to statics |
11 | .help = consider extracting the value of the `static` to a `const`, and referring to that | |
f2b60f7d FG |
12 | .teach_note = `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. |
13 | .teach_help = To fix this, the value can be extracted to a `const` and then used. | |
064997fb | 14 | |
f2b60f7d | 15 | const_eval_raw_ptr_to_int = |
064997fb FG |
16 | pointers cannot be cast to integers during const eval |
17 | .note = at compile-time, pointers do not have an integer value | |
18 | .note2 = avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior | |
19 | ||
f2b60f7d | 20 | const_eval_raw_ptr_comparison = |
064997fb FG |
21 | pointers cannot be reliably compared during const eval |
22 | .note = see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information | |
23 | ||
f2b60f7d | 24 | const_eval_panic_non_str = argument to `panic!()` in a const context must have type `&str` |
064997fb | 25 | |
f2b60f7d | 26 | const_eval_mut_deref = |
064997fb FG |
27 | mutation through a reference is not allowed in {$kind}s |
28 | ||
f2b60f7d | 29 | const_eval_transient_mut_borrow = mutable references are not allowed in {$kind}s |
064997fb | 30 | |
f2b60f7d FG |
31 | const_eval_transient_mut_borrow_raw = raw mutable references are not allowed in {$kind}s |
32 | ||
33 | const_eval_max_num_nodes_in_const = maximum number of nodes exceeded in constant {$global_const_id} | |
34 | ||
35 | const_eval_unallowed_fn_pointer_call = function pointer calls are not allowed in {$kind}s | |
36 | ||
37 | const_eval_unstable_const_fn = `{$def_path}` is not yet stable as a const fn | |
38 | ||
39 | const_eval_unallowed_mutable_refs = | |
40 | mutable references are not allowed in the final value of {$kind}s | |
41 | .teach_note = | |
42 | References in statics and constants may only refer to immutable values.\n\n | |
43 | Statics are shared everywhere, and if they refer to mutable data one might violate memory | |
44 | safety since holding multiple mutable references to shared data is not allowed.\n\n | |
45 | If you really want global mutable state, try using static mut or a global UnsafeCell. | |
46 | ||
47 | const_eval_unallowed_mutable_refs_raw = | |
48 | raw mutable references are not allowed in the final value of {$kind}s | |
49 | .teach_note = | |
50 | References in statics and constants may only refer to immutable values.\n\n | |
51 | Statics are shared everywhere, and if they refer to mutable data one might violate memory | |
52 | safety since holding multiple mutable references to shared data is not allowed.\n\n | |
53 | If you really want global mutable state, try using static mut or a global UnsafeCell. | |
54 | ||
55 | const_eval_non_const_fmt_macro_call = | |
56 | cannot call non-const formatting macro in {$kind}s | |
57 | ||
58 | const_eval_non_const_fn_call = | |
59 | cannot call non-const fn `{$def_path_str}` in {$kind}s | |
60 | ||
61 | const_eval_unallowed_op_in_const_context = | |
62 | {$msg} | |
63 | ||
64 | const_eval_unallowed_heap_allocations = | |
65 | allocations are not allowed in {$kind}s | |
66 | .label = allocation not allowed in {$kind}s | |
67 | .teach_note = | |
68 | 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. | |
69 | ||
70 | const_eval_unallowed_inline_asm = | |
71 | inline assembly is not allowed in {$kind}s | |
72 | ||
73 | const_eval_interior_mutable_data_refer = | |
74 | {$kind}s cannot refer to interior mutable data | |
75 | .label = this borrow of an interior mutable value may end up in the final value | |
76 | .help = to fix this, the value can be extracted to a separate `static` item and then referenced | |
77 | .teach_note = | |
78 | A constant containing interior mutable data behind a reference can allow you to modify that data. | |
79 | This would make multiple uses of a constant to be able to see different values and allow circumventing | |
80 | the `Send` and `Sync` requirements for shared mutable data, which is unsound. | |
81 | ||
82 | const_eval_interior_mutability_borrow = | |
83 | cannot borrow here, since the borrowed element may contain interior mutability |