Skip to content

Commit 8244230

Browse files
Fix tests from bless
1 parent e58165e commit 8244230

6 files changed

+122
-157
lines changed

src/test/ui/const-ptr/forbidden_slices.64bit.be.stderr

+112-79
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>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
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:19:34
10+
LL | &*ptr::slice_from_raw_parts(data, len)
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
note: inside `S0`
13+
--> $DIR/forbidden_slices.rs:19:34
1114
|
1215
LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
13-
| ------------------------------ inside `S0` at $DIR/forbidden_slices.rs:19:34
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::<'_, ()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
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:20:33
27+
LL | &*ptr::slice_from_raw_parts(data, len)
28+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29+
note: inside `S1`
30+
--> $DIR/forbidden_slices.rs:20:33
2531
|
2632
LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
27-
| ------------------------------ inside `S1` at $DIR/forbidden_slices.rs:20:33
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>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
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:23:34
44+
LL | &*ptr::slice_from_raw_parts(data, len)
45+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46+
note: inside `S2`
47+
--> $DIR/forbidden_slices.rs:23:34
3948
|
4049
LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
41-
| ---------------------- inside `S2` at $DIR/forbidden_slices.rs:23:34
50+
| ^^^^^^^^^^^^^^^^^^^^^^
4251

4352
error[E0080]: it is undefined behavior to use this value
4453
--> $DIR/forbidden_slices.rs:26:1
@@ -67,7 +76,7 @@ error[E0080]: it is undefined behavior to use this value
6776
--> $DIR/forbidden_slices.rs:30:1
6877
|
6978
LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
70-
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
79+
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[3]: encountered 0x11, but expected a boolean
7180
|
7281
= 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.
7382
= note: the raw bytes of the constant (size: 16, align: 8) {
@@ -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>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
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:44: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:44:5
98110
|
99111
LL | from_raw_parts(ptr, 1)
100-
| ---------------------- inside `S8` at $DIR/forbidden_slices.rs:44:5
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` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
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>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
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:47: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:47:34
117132
|
118133
LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
119-
| ---------------------------------------- inside `R0` at $DIR/forbidden_slices.rs:47:34
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` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
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::<'_, ()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
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:48: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:48:33
136154
|
137155
LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
138-
| ---------------------------------------- inside `R1` at $DIR/forbidden_slices.rs:48:33
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` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
150-
...
151-
LL | unsafe { self.offset(count as isize) }
152-
| --------------------------- inside `ptr::const_ptr::<impl *const u32>::add` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
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:51:25
173+
LL | unsafe { self.offset(count as isize) }
174+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
175+
note: inside `R2`
176+
--> $DIR/forbidden_slices.rs:51:25
155177
|
156178
LL | from_ptr_range(ptr..ptr.add(2))
157-
| ---------- inside `R2` at $DIR/forbidden_slices.rs:51:25
179+
| ^^^^^^^^^^
158180

159181
error[E0080]: it is undefined behavior to use this value
160182
--> $DIR/forbidden_slices.rs:53:1
@@ -183,7 +205,7 @@ error[E0080]: it is undefined behavior to use this value
183205
--> $DIR/forbidden_slices.rs:63:1
184206
|
185207
LL | pub static R6: &[bool] = unsafe {
186-
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
208+
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[3]: encountered 0x11, but expected a boolean
187209
|
188210
= 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.
189211
= note: the raw bytes of the constant (size: 16, align: 8) {
@@ -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` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
212-
...
213-
LL | unsafe { self.offset(count as isize) }
214-
| --------------------------- inside `ptr::const_ptr::<impl *const u64>::add` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
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:75:25
240+
LL | unsafe { self.offset(count as isize) }
241+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
242+
note: inside `R8`
243+
--> $DIR/forbidden_slices.rs:75:25
217244
|
218245
LL | from_ptr_range(ptr..ptr.add(1))
219-
| ---------- inside `R8` at $DIR/forbidden_slices.rs:75:25
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` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
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>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
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:80: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:80:34
236266
|
237267
LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
238-
| ----------------------------------------------- inside `R9` at $DIR/forbidden_slices.rs:80:34
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` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
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>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
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:81: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:81:35
255288
|
256289
LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
257-
| ------------------------ inside `R10` at $DIR/forbidden_slices.rs:81:35
290+
| ^^^^^^^^^^^^^^^^^^^^^^^^
258291

259292
error: aborting due to 18 previous errors
260293

src/test/ui/consts/const-eval/ub-enum.64bit.be.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran
101101
|
102102
= 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.
103103
= note: the raw bytes of the constant (size: 8, align: 4) {
104-
00 00 00 78 ff ff ff ff │ x.......
104+
00 00 00 78 ff ff ff ff │ ...x....
105105
}
106106

107107
error[E0080]: evaluation of constant value failed

0 commit comments

Comments
 (0)