-warning: any use of this value will cause an error
- --> $DIR/const_refers_to_static.rs:17:5
- |
-LL | / const MUTATE_INTERIOR_MUT: usize = {
-LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
-LL | | FOO.fetch_add(1, Ordering::Relaxed)
- | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling non-const function `std::sync::atomic::AtomicUsize::fetch_add`
-LL | |
-LL | |
-LL | | };
- | |__-
- |
-note: the lint level is defined here
- --> $DIR/const_refers_to_static.rs:2:9
- |
-LL | #![warn(const_err)]
- | ^^^^^^^^^
-
-warning: any use of this value will cause an error
- --> $DIR/const_refers_to_static.rs:24:14
- |
-LL | / const READ_INTERIOR_MUT: usize = {
-LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
-LL | | unsafe { *(&FOO as *const _ as *const usize) }
- | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static
-LL | |
-LL | | };
- | |__-
-
-warning: any use of this value will cause an error
- --> $DIR/const_refers_to_static.rs:29:32
- |
-LL | const READ_MUT: u32 = unsafe { MUTABLE };
- | -------------------------------^^^^^^^---
- | |
- | constant accesses static
-
-error[E0080]: it is undefined behavior to use this value
- --> $DIR/const_refers_to_static.rs:34:1
- |
-LL | / const READ_IMMUT: &usize = {
-LL | | static FOO: usize = 0;
-LL | | &FOO
-LL | |
-LL | | };
- | |__^ type validation failed: encountered a reference pointing to a static variable