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