]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-ptr/forbidden_slices.32bit.stderr
Auto merge of #104334 - compiler-errors:ufcs-sugg-wrong-def-id, r=estebank
[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: allocN 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 at .<deref>[1]: encountered uninitialized bytes
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                ╾ALLOC_ID+0x2╼ 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: allocN 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: allocN 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]: could not evaluate static initializer
179   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
180    |
181    = note: accessing memory with alignment 1, but alignment 2 is required
182    |
183 note: inside `std::slice::from_raw_parts::<'_, u16>`
184   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
185 note: inside `from_ptr_range::<'_, u16>`
186   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
187 note: inside `R7`
188   --> $DIR/forbidden_slices.rs:69:5
189    |
190 LL |     from_ptr_range(ptr..ptr.add(4))
191    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
192
193 error[E0080]: could not evaluate static initializer
194   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
195    |
196    = note: out-of-bounds pointer arithmetic: allocN has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
197    |
198 note: inside `ptr::const_ptr::<impl *const u64>::offset`
199   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
200 note: inside `ptr::const_ptr::<impl *const u64>::add`
201   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
202 note: inside `R8`
203   --> $DIR/forbidden_slices.rs:73:25
204    |
205 LL |     from_ptr_range(ptr..ptr.add(1))
206    |                         ^^^^^^^^^^
207
208 error[E0080]: could not evaluate static initializer
209   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
210    |
211    = note: `ptr_offset_from_unsigned` called on pointers into different allocations
212    |
213 note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
214   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
215 note: inside `from_ptr_range::<'_, u32>`
216   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
217 note: inside `R9`
218   --> $DIR/forbidden_slices.rs:78:34
219    |
220 LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
221    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
222
223 error[E0080]: could not evaluate static initializer
224   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
225    |
226    = note: `ptr_offset_from_unsigned` called on pointers into different allocations
227    |
228 note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
229   --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
230 note: inside `from_ptr_range::<'_, u32>`
231   --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
232 note: inside `R10`
233   --> $DIR/forbidden_slices.rs:79:35
234    |
235 LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
236    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^
237
238 error: aborting due to 18 previous errors
239
240 For more information about this error, try `rustc --explain E0080`.