Skip to content

Commit 18a2c28

Browse files
committed
Bless 32 bit tests
1 parent 1ccac16 commit 18a2c28

File tree

2 files changed

+120
-82
lines changed

2 files changed

+120
-82
lines changed

src/test/ui/const-ptr/forbidden_slices.32bit.stderr

Lines changed: 110 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,52 @@ error[E0080]: could not evaluate static initializer
22
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
33
|
44
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>`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
6+
|
7+
note: inside `std::slice::from_raw_parts::<'_, u32>`
8+
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
99
|
10-
::: $DIR/forbidden_slices.rs:18:34
10+
LL | &*ptr::slice_from_raw_parts(data, len)
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
note: inside `S0`
13+
--> $DIR/forbidden_slices.rs:18:34
1114
|
1215
LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
13-
| ------------------------------ inside `S0`
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1417

1518
error[E0080]: could not evaluate static initializer
1619
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
1720
|
1821
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::<'_, ()>`
22+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
23+
|
24+
note: inside `std::slice::from_raw_parts::<'_, ()>`
25+
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
2326
|
24-
::: $DIR/forbidden_slices.rs:19:33
27+
LL | &*ptr::slice_from_raw_parts(data, len)
28+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29+
note: inside `S1`
30+
--> $DIR/forbidden_slices.rs:19:33
2531
|
2632
LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
27-
| ------------------------------ inside `S1`
33+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2834

2935
error[E0080]: could not evaluate static initializer
3036
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
3137
|
3238
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>`
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
40+
|
41+
note: inside `std::slice::from_raw_parts::<'_, u32>`
42+
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
3743
|
38-
::: $DIR/forbidden_slices.rs:22:34
44+
LL | &*ptr::slice_from_raw_parts(data, len)
45+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46+
note: inside `S2`
47+
--> $DIR/forbidden_slices.rs:22:34
3948
|
4049
LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
41-
| ---------------------- inside `S2`
50+
| ^^^^^^^^^^^^^^^^^^^^^^
4251

4352
error[E0080]: it is undefined behavior to use this value
4453
--> $DIR/forbidden_slices.rs:25:1
@@ -89,72 +98,85 @@ error[E0080]: could not evaluate static initializer
8998
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
9099
|
91100
LL | &*ptr::slice_from_raw_parts(data, len)
92-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93-
| |
94-
| dereferencing pointer failed: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
95-
| inside `std::slice::from_raw_parts::<'_, u64>`
101+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
96102
|
97-
::: $DIR/forbidden_slices.rs:43:5
103+
note: inside `std::slice::from_raw_parts::<'_, u64>`
104+
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
105+
|
106+
LL | &*ptr::slice_from_raw_parts(data, len)
107+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
108+
note: inside `S8`
109+
--> $DIR/forbidden_slices.rs:43:5
98110
|
99111
LL | from_raw_parts(ptr, 1)
100-
| ---------------------- inside `S8`
112+
| ^^^^^^^^^^^^^^^^^^^^^^
101113

102114
error[E0080]: could not evaluate static initializer
103115
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
104116
|
105117
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
106-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
107-
| |
108-
| out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance)
109-
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
118+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance)
110119
|
111-
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
120+
note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
121+
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
112122
|
113-
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
114-
| ------------------------------ inside `from_ptr_range::<'_, u32>`
123+
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
124+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
125+
note: inside `from_ptr_range::<'_, u32>`
126+
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
115127
|
116-
::: $DIR/forbidden_slices.rs:46:34
128+
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
129+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
130+
note: inside `R0`
131+
--> $DIR/forbidden_slices.rs:46:34
117132
|
118133
LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
119-
| ---------------------------------------- inside `R0`
134+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
120135

121136
error[E0080]: could not evaluate static initializer
122137
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
123138
|
124139
LL | assert!(0 < pointee_size && pointee_size <= isize::MAX as usize);
125-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
126-
| |
127-
| 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
128-
| inside `ptr::const_ptr::<impl *const ()>::sub_ptr`
140+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
129141
|
130-
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
142+
note: inside `ptr::const_ptr::<impl *const ()>::sub_ptr`
143+
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
131144
|
132-
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
133-
| ------------------------------ inside `from_ptr_range::<'_, ()>`
145+
LL | assert!(0 < pointee_size && pointee_size <= isize::MAX as usize);
146+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
147+
note: inside `from_ptr_range::<'_, ()>`
148+
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
134149
|
135-
::: $DIR/forbidden_slices.rs:47:33
150+
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
151+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
152+
note: inside `R1`
153+
--> $DIR/forbidden_slices.rs:47:33
136154
|
137155
LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
138-
| ---------------------------------------- inside `R1`
139-
|
156+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
140157
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
141158

142159
error[E0080]: could not evaluate static initializer
143160
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
144161
|
162+
LL | unsafe { intrinsics::offset(self, count) }
163+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
164+
|
165+
note: inside `ptr::const_ptr::<impl *const u32>::offset`
166+
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
167+
|
145168
LL | unsafe { intrinsics::offset(self, count) }
146169
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
147-
| |
148-
| out-of-bounds pointer arithmetic: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
149-
| inside `ptr::const_ptr::<impl *const u32>::offset`
150-
...
151-
LL | unsafe { self.offset(count as isize) }
152-
| --------------------------- inside `ptr::const_ptr::<impl *const u32>::add`
170+
note: inside `ptr::const_ptr::<impl *const u32>::add`
171+
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
153172
|
154-
::: $DIR/forbidden_slices.rs:50:25
173+
LL | unsafe { self.offset(count as isize) }
174+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
175+
note: inside `R2`
176+
--> $DIR/forbidden_slices.rs:50:25
155177
|
156178
LL | from_ptr_range(ptr..ptr.add(2))
157-
| ---------- inside `R2`
179+
| ^^^^^^^^^^
158180

159181
error[E0080]: it is undefined behavior to use this value
160182
--> $DIR/forbidden_slices.rs:52:1
@@ -204,57 +226,68 @@ LL | pub static R7: &[u16] = unsafe {
204226
error[E0080]: could not evaluate static initializer
205227
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
206228
|
229+
LL | unsafe { intrinsics::offset(self, count) }
230+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
231+
|
232+
note: inside `ptr::const_ptr::<impl *const u64>::offset`
233+
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
234+
|
207235
LL | unsafe { intrinsics::offset(self, count) }
208236
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
209-
| |
210-
| out-of-bounds pointer arithmetic: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
211-
| inside `ptr::const_ptr::<impl *const u64>::offset`
212-
...
213-
LL | unsafe { self.offset(count as isize) }
214-
| --------------------------- inside `ptr::const_ptr::<impl *const u64>::add`
237+
note: inside `ptr::const_ptr::<impl *const u64>::add`
238+
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
215239
|
216-
::: $DIR/forbidden_slices.rs:74:25
240+
LL | unsafe { self.offset(count as isize) }
241+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
242+
note: inside `R8`
243+
--> $DIR/forbidden_slices.rs:74:25
217244
|
218245
LL | from_ptr_range(ptr..ptr.add(1))
219-
| ---------- inside `R8`
246+
| ^^^^^^^^^^
220247

221248
error[E0080]: could not evaluate static initializer
222249
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
223250
|
224251
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
225-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
226-
| |
227-
| `ptr_offset_from_unsigned` called on pointers into different allocations
228-
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
252+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on pointers into different allocations
229253
|
230-
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
254+
note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
255+
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
231256
|
232-
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
233-
| ------------------------------ inside `from_ptr_range::<'_, u32>`
257+
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
258+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
259+
note: inside `from_ptr_range::<'_, u32>`
260+
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
234261
|
235-
::: $DIR/forbidden_slices.rs:79:34
262+
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
263+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
264+
note: inside `R9`
265+
--> $DIR/forbidden_slices.rs:79:34
236266
|
237267
LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
238-
| ----------------------------------------------- inside `R9`
268+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
239269

240270
error[E0080]: could not evaluate static initializer
241271
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
242272
|
243273
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
244-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
245-
| |
246-
| `ptr_offset_from_unsigned` called on pointers into different allocations
247-
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
274+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on pointers into different allocations
248275
|
249-
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
276+
note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
277+
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
250278
|
251-
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
252-
| ------------------------------ inside `from_ptr_range::<'_, u32>`
279+
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
280+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
281+
note: inside `from_ptr_range::<'_, u32>`
282+
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
253283
|
254-
::: $DIR/forbidden_slices.rs:80:35
284+
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
285+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
286+
note: inside `R10`
287+
--> $DIR/forbidden_slices.rs:80:35
255288
|
256289
LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
257-
| ------------------------ inside `R10`
290+
| ^^^^^^^^^^^^^^^^^^^^^^^^
258291

259292
error: aborting due to 18 previous errors
260293

src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,19 @@ LL | unsafe { std::mem::transmute(()) }
1313
error[E0080]: evaluation of constant value failed
1414
--> $DIR/validate_uninhabited_zsts.rs:4:14
1515
|
16+
LL | unsafe { std::mem::transmute(()) }
17+
| ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type
18+
|
19+
note: inside `foo`
20+
--> $DIR/validate_uninhabited_zsts.rs:4:14
21+
|
1622
LL | unsafe { std::mem::transmute(()) }
1723
| ^^^^^^^^^^^^^^^^^^^^^^^
18-
| |
19-
| transmuting to uninhabited type
20-
| inside `foo`
21-
...
24+
note: inside `FOO`
25+
--> $DIR/validate_uninhabited_zsts.rs:19:33
26+
|
2227
LL | const FOO: [empty::Empty; 3] = [foo(); 3];
23-
| ----- inside `FOO`
28+
| ^^^^^
2429

2530
error[E0080]: it is undefined behavior to use this value
2631
--> $DIR/validate_uninhabited_zsts.rs:21:1

0 commit comments

Comments
 (0)