]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-ptr/forbidden_slices.32bit.stderr
drive-by: Fix path spans
[rust.git] / src / test / ui / const-ptr / forbidden_slices.32bit.stderr
1 error[E0080]: could not evaluate static initializer
2   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
3    |
4    = note: dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
5    |
6 note: inside `std::slice::from_raw_parts::<'_, u32>`
7   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
8 note: inside `S0`
9   --> $DIR/forbidden_slices.rs:18:34
10    |
11 LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
12    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13
14 error[E0080]: could not evaluate static initializer
15   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
16    |
17    = note: dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
18    |
19 note: inside `std::slice::from_raw_parts::<'_, ()>`
20   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
21 note: inside `S1`
22   --> $DIR/forbidden_slices.rs:19:33
23    |
24 LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
25    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26
27 error[E0080]: could not evaluate static initializer
28   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
29    |
30    = note: dereferencing pointer failed: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
31    |
32 note: inside `std::slice::from_raw_parts::<'_, u32>`
33   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
34 note: inside `S2`
35   --> $DIR/forbidden_slices.rs:22:34
36    |
37 LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
38    |                                  ^^^^^^^^^^^^^^^^^^^^^^
39
40 error[E0080]: it is undefined behavior to use this value
41   --> $DIR/forbidden_slices.rs:25:1
42    |
43 LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
44    | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized bytes
45    |
46    = 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.
47    = note: the raw bytes of the constant (size: 8, align: 4) {
48                ╾─ALLOC_ID─╼ 01 00 00 00                         │ ╾──╼....
49            }
50
51 error[E0080]: it is undefined behavior to use this value
52   --> $DIR/forbidden_slices.rs:27:1
53    |
54 LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) };
55    | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
56    |
57    = help: this code performed an operation that depends on the underlying bytes representing a pointer
58    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
59    = note: the raw bytes of the constant (size: 8, align: 4) {
60                ╾─ALLOC_ID─╼ 04 00 00 00                         │ ╾──╼....
61            }
62
63 error[E0080]: it is undefined behavior to use this value
64   --> $DIR/forbidden_slices.rs:29:1
65    |
66 LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
67    | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
68    |
69    = 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.
70    = note: the raw bytes of the constant (size: 8, align: 4) {
71                ╾─ALLOC_ID─╼ 04 00 00 00                         │ ╾──╼....
72            }
73
74 error[E0080]: it is undefined behavior to use this value
75   --> $DIR/forbidden_slices.rs:32:1
76    |
77 LL | pub static S7: &[u16] = unsafe {
78    | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
79    |
80    = 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.
81    = note: the raw bytes of the constant (size: 8, align: 4) {
82                ╾─A_ID+0x1─╼ 04 00 00 00                         │ ╾──╼....
83            }
84
85 error[E0080]: could not evaluate static initializer
86   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
87    |
88    = note: dereferencing pointer failed: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
89    |
90 note: inside `std::slice::from_raw_parts::<'_, u64>`
91   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
92 note: inside `S8`
93   --> $DIR/forbidden_slices.rs:43:5
94    |
95 LL |     from_raw_parts(ptr, 1)
96    |     ^^^^^^^^^^^^^^^^^^^^^^
97
98 error[E0080]: could not evaluate static initializer
99   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
100    |
101    = note: out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance)
102    |
103 note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
104   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
105 note: inside `from_ptr_range::<'_, u32>`
106   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
107 note: inside `R0`
108   --> $DIR/forbidden_slices.rs:46:34
109    |
110 LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
111    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
112
113 error[E0080]: could not evaluate static initializer
114   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
115    |
116    = note: the evaluated program panicked at 'assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize', $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
117    |
118 note: inside `ptr::const_ptr::<impl *const ()>::sub_ptr`
119   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
120 note: inside `from_ptr_range::<'_, ()>`
121   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
122 note: inside `R1`
123   --> $DIR/forbidden_slices.rs:47:33
124    |
125 LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
126    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127    = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
128
129 error[E0080]: could not evaluate static initializer
130   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
131    |
132    = note: out-of-bounds pointer arithmetic: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
133    |
134 note: inside `ptr::const_ptr::<impl *const u32>::offset`
135   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
136 note: inside `ptr::const_ptr::<impl *const u32>::add`
137   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
138 note: inside `R2`
139   --> $DIR/forbidden_slices.rs:50:25
140    |
141 LL |     from_ptr_range(ptr..ptr.add(2))
142    |                         ^^^^^^^^^^
143
144 error[E0080]: it is undefined behavior to use this value
145   --> $DIR/forbidden_slices.rs:52:1
146    |
147 LL | pub static R4: &[u8] = unsafe {
148    | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized bytes
149    |
150    = 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.
151    = note: the raw bytes of the constant (size: 8, align: 4) {
152                ╾ALLOC_ID─╼ 01 00 00 00                         │ ╾──╼....
153            }
154
155 error[E0080]: it is undefined behavior to use this value
156   --> $DIR/forbidden_slices.rs:57:1
157    |
158 LL | pub static R5: &[u8] = unsafe {
159    | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
160    |
161    = help: this code performed an operation that depends on the underlying bytes representing a pointer
162    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
163    = note: the raw bytes of the constant (size: 8, align: 4) {
164                ╾ALLOC_ID─╼ 04 00 00 00                         │ ╾──╼....
165            }
166
167 error[E0080]: it is undefined behavior to use this value
168   --> $DIR/forbidden_slices.rs:62:1
169    |
170 LL | pub static R6: &[bool] = unsafe {
171    | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
172    |
173    = 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.
174    = note: the raw bytes of the constant (size: 8, align: 4) {
175                ╾ALLOC_ID─╼ 04 00 00 00                         │ ╾──╼....
176            }
177
178 error[E0080]: it is undefined behavior to use this value
179   --> $DIR/forbidden_slices.rs:67:1
180    |
181 LL | pub static R7: &[u16] = unsafe {
182    | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
183    |
184    = 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.
185    = note: the raw bytes of the constant (size: 8, align: 4) {
186                ╾A_ID+0x1─╼ 04 00 00 00                         │ ╾──╼....
187            }
188
189 error[E0080]: could not evaluate static initializer
190   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
191    |
192    = note: out-of-bounds pointer arithmetic: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
193    |
194 note: inside `ptr::const_ptr::<impl *const u64>::offset`
195   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
196 note: inside `ptr::const_ptr::<impl *const u64>::add`
197   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
198 note: inside `R8`
199   --> $DIR/forbidden_slices.rs:74:25
200    |
201 LL |     from_ptr_range(ptr..ptr.add(1))
202    |                         ^^^^^^^^^^
203
204 error[E0080]: could not evaluate static initializer
205   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
206    |
207    = note: `ptr_offset_from_unsigned` called on pointers into different allocations
208    |
209 note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
210   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
211 note: inside `from_ptr_range::<'_, u32>`
212   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
213 note: inside `R9`
214   --> $DIR/forbidden_slices.rs:79:34
215    |
216 LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
217    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
218
219 error[E0080]: could not evaluate static initializer
220   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
221    |
222    = note: `ptr_offset_from_unsigned` called on pointers into different allocations
223    |
224 note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
225   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
226 note: inside `from_ptr_range::<'_, u32>`
227   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
228 note: inside `R10`
229   --> $DIR/forbidden_slices.rs:80:35
230    |
231 LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
232    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^
233
234 error: aborting due to 18 previous errors
235
236 For more information about this error, try `rustc --explain E0080`.