1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
error[E0080]: calling non-const function `AtomicUsize::fetch_add`
--> $DIR/const_refers_to_static.rs:11:5
|
LL | FOO.fetch_add(1, Ordering::Relaxed)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MUTATE_INTERIOR_MUT` failed here
error[E0080]: constant accesses mutable global memory
--> $DIR/const_refers_to_static.rs:16:14
|
LL | unsafe { *(&FOO as *const _ as *const usize) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `READ_INTERIOR_MUT` failed here
error[E0080]: constant accesses mutable global memory
--> $DIR/const_refers_to_static.rs:20:32
|
LL | const READ_MUT: u32 = unsafe { MUTABLE };
| ^^^^^^^ evaluation of `READ_MUT` failed here
error[E0080]: constructing invalid value: encountered reference to mutable memory in `const`
--> $DIR/const_refers_to_static.rs:23:1
|
LL | const REF_INTERIOR_MUT: &usize = {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
warning: skipping const checks
|
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static.rs:11:5
|
LL | FOO.fetch_add(1, Ordering::Relaxed)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0080`.
|