Debian Codegraph @

third_party/rust/zerocopy/tests/ui-nightly/transmute-mut-const.stderr

raw
1 warning: taking a mutable reference to a `const` item
2 --> tests/ui-nightly/transmute-mut-const.rs:20:52
3 |
4 20 | const CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
5 | ^^^^^^^^^^^^^^^^^
6 |
7 = note: each usage of a `const` item creates a new temporary
8 = note: the mutable reference will refer to this temporary, not the original `const` item
9 note: `const` item defined here
10 --> tests/ui-nightly/transmute-mut-const.rs:17:1
11 |
12 17 | const ARRAY_OF_U8S: [u8; 2] = [0u8; 2];
13 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
14 = note: `#[warn(const_item_mutation)]` on by default
15
16 error[E0658]: mutable references are not allowed in constants
17 --> tests/ui-nightly/transmute-mut-const.rs:20:52
18 |
19 20 | const CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
20 | ^^^^^^^^^^^^^^^^^
21 |
22 = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
23 = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
24
25 error[E0015]: cannot call non-const fn `transmute_mut::<'_, '_, [u8; 2], [u8; 2]>` in constants
26 --> tests/ui-nightly/transmute-mut-const.rs:20:37
27 |
28 20 | const CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
29 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30 |
31 = note: calls in constants are limited to constant functions, tuple structs and tuple variants
32 = note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
33
34 error[E0716]: temporary value dropped while borrowed
35 --> tests/ui-nightly/transmute-mut-const.rs:20:57
36 |
37 20 | const CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
38 | --------------------^^^^^^^^^^^^-
39 | | |
40 | | creates a temporary value which is freed while still in use
41 | temporary value is freed at the end of this statement
42 | using this value as a constant requires that borrow lasts for `'static`