summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr
blob: f1f58d9ca6d6f64351806041e8f6acd587d664a4 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
error[E0080]: evaluation of constant value failed
  --> $DIR/const_refers_to_static.rs:9:5
   |
LL |     FOO.fetch_add(1, Ordering::Relaxed)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling non-const function `AtomicUsize::fetch_add`

error[E0080]: evaluation of constant value failed
  --> $DIR/const_refers_to_static.rs:14:14
   |
LL |     unsafe { *(&FOO as *const _ as *const usize) }
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static

error[E0080]: evaluation of constant value failed
  --> $DIR/const_refers_to_static.rs:18: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:20:1
   |
LL | const REF_INTERIOR_MUT: &usize = {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
   |
   = 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: 8, align: 8) {
               ╾ALLOC0<imm>╼                         │ ╾──────╼
           }

error[E0080]: it is undefined behavior to use this value
  --> $DIR/const_refers_to_static.rs:27:1
   |
LL | const READ_IMMUT: &usize = {
   | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
   |
   = 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: 8, align: 8) {
               ╾ALLOC1<imm>╼                         │ ╾──────╼
           }

warning: skipping const checks
   |
help: skipping check that does not even have a feature gate
  --> $DIR/const_refers_to_static.rs:9:5
   |
LL |     FOO.fetch_add(1, Ordering::Relaxed)
   |     ^^^
help: skipping check that does not even have a feature gate
  --> $DIR/const_refers_to_static.rs:9:5
   |
LL |     FOO.fetch_add(1, Ordering::Relaxed)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
  --> $DIR/const_refers_to_static.rs:14:17
   |
LL |     unsafe { *(&FOO as *const _ as *const usize) }
   |                 ^^^
help: skipping check that does not even have a feature gate
  --> $DIR/const_refers_to_static.rs:18:32
   |
LL | const READ_MUT: u32 = unsafe { MUTABLE };
   |                                ^^^^^^^
help: skipping check that does not even have a feature gate
  --> $DIR/const_refers_to_static.rs:18:32
   |
LL | const READ_MUT: u32 = unsafe { MUTABLE };
   |                                ^^^^^^^
help: skipping check that does not even have a feature gate
  --> $DIR/const_refers_to_static.rs:23:18
   |
LL |     unsafe { &*(&FOO as *const _ as *const usize) }
   |                  ^^^
help: skipping check that does not even have a feature gate
  --> $DIR/const_refers_to_static.rs:30:6
   |
LL |     &FOO
   |      ^^^

error: aborting due to 5 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0080`.