Skip to content

Commit 1e0747f

Browse files
committed
normalize forbidden slices
1 parent 1f8a641 commit 1e0747f

File tree

3 files changed

+79
-78
lines changed

3 files changed

+79
-78
lines changed

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

+38-38
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ LL | &*ptr::slice_from_raw_parts(data, len)
77
| dereferencing pointer failed: null pointer is not a valid pointer
88
| inside `std::slice::from_raw_parts::<u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
99
|
10-
::: $DIR/forbidden_slices.rs:17:34
10+
::: $DIR/forbidden_slices.rs:18:34
1111
|
1212
LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
13-
| ------------------------------ inside `S0` at $DIR/forbidden_slices.rs:17:34
13+
| ------------------------------ inside `S0` at $DIR/forbidden_slices.rs:18:34
1414

1515
error[E0080]: could not evaluate static initializer
1616
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
@@ -21,60 +21,60 @@ LL | &*ptr::slice_from_raw_parts(data, len)
2121
| dereferencing pointer failed: null pointer is not a valid pointer
2222
| inside `std::slice::from_raw_parts::<()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
2323
|
24-
::: $DIR/forbidden_slices.rs:18:33
24+
::: $DIR/forbidden_slices.rs:19:33
2525
|
2626
LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
27-
| ------------------------------ inside `S1` at $DIR/forbidden_slices.rs:18:33
27+
| ------------------------------ inside `S1` at $DIR/forbidden_slices.rs:19:33
2828

2929
error[E0080]: could not evaluate static initializer
3030
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
3131
|
3232
LL | &*ptr::slice_from_raw_parts(data, len)
3333
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3434
| |
35-
| dereferencing pointer failed: alloc26 has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
35+
| dereferencing pointer failed: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
3636
| inside `std::slice::from_raw_parts::<u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
3737
|
38-
::: $DIR/forbidden_slices.rs:21:34
38+
::: $DIR/forbidden_slices.rs:22:34
3939
|
4040
LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
41-
| ---------------------- inside `S2` at $DIR/forbidden_slices.rs:21:34
41+
| ---------------------- inside `S2` at $DIR/forbidden_slices.rs:22:34
4242

4343
error[E0080]: it is undefined behavior to use this value
44-
--> $DIR/forbidden_slices.rs:24:1
44+
--> $DIR/forbidden_slices.rs:25:1
4545
|
4646
LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
4747
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>[0]: encountered uninitialized bytes
4848
|
4949
= 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.
5050
= note: the raw bytes of the constant (size: 8, align: 4) {
51-
╾─alloc42─╼ 01 00 00 00 │ ╾──╼....
51+
╾─ALLOC_ID─╼ 01 00 00 00 │ ╾──╼....
5252
}
5353

5454
error[E0080]: it is undefined behavior to use this value
55-
--> $DIR/forbidden_slices.rs:26:1
55+
--> $DIR/forbidden_slices.rs:27:1
5656
|
5757
LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) };
5858
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>: encountered a pointer, but expected plain (non-pointer) bytes
5959
|
6060
= 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.
6161
= note: the raw bytes of the constant (size: 8, align: 4) {
62-
╾─alloc55─╼ 04 00 00 00 │ ╾──╼....
62+
╾─ALLOC_ID─╼ 04 00 00 00 │ ╾──╼....
6363
}
6464

6565
error[E0080]: it is undefined behavior to use this value
66-
--> $DIR/forbidden_slices.rs:28:1
66+
--> $DIR/forbidden_slices.rs:29:1
6767
|
6868
LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
6969
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>[0]: encountered 0x11, but expected a boolean
7070
|
7171
= 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.
7272
= note: the raw bytes of the constant (size: 8, align: 4) {
73-
╾─alloc65─╼ 04 00 00 00 │ ╾──╼....
73+
╾─ALLOC_ID─╼ 04 00 00 00 │ ╾──╼....
7474
}
7575

7676
error[E0080]: it is undefined behavior to use this value
77-
--> $DIR/forbidden_slices.rs:31:1
77+
--> $DIR/forbidden_slices.rs:32:1
7878
|
7979
LL | / pub static S7: &[u16] = unsafe {
8080
LL | |
@@ -95,13 +95,13 @@ error[E0080]: could not evaluate static initializer
9595
LL | &*ptr::slice_from_raw_parts(data, len)
9696
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9797
| |
98-
| dereferencing pointer failed: alloc96 has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
98+
| dereferencing pointer failed: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
9999
| inside `std::slice::from_raw_parts::<u64>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
100100
|
101-
::: $DIR/forbidden_slices.rs:42:5
101+
::: $DIR/forbidden_slices.rs:43:5
102102
|
103103
LL | from_raw_parts(ptr, 1)
104-
| ---------------------- inside `S8` at $DIR/forbidden_slices.rs:42:5
104+
| ---------------------- inside `S8` at $DIR/forbidden_slices.rs:43:5
105105

106106
error[E0080]: could not evaluate static initializer
107107
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -117,10 +117,10 @@ LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
117117
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
118118
| ------------------------------ inside `from_ptr_range::<u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
119119
|
120-
::: $DIR/forbidden_slices.rs:45:34
120+
::: $DIR/forbidden_slices.rs:46:34
121121
|
122122
LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
123-
| ---------------------------------------- inside `R0` at $DIR/forbidden_slices.rs:45:34
123+
| ---------------------------------------- inside `R0` at $DIR/forbidden_slices.rs:46:34
124124

125125
error[E0080]: could not evaluate static initializer
126126
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -136,10 +136,10 @@ LL | assert!(0 < pointee_size && pointee_size <= isize::MAX as usize);
136136
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
137137
| ------------------------------ inside `from_ptr_range::<()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
138138
|
139-
::: $DIR/forbidden_slices.rs:46:33
139+
::: $DIR/forbidden_slices.rs:47:33
140140
|
141141
LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
142-
| ---------------------------------------- inside `R1` at $DIR/forbidden_slices.rs:46:33
142+
| ---------------------------------------- inside `R1` at $DIR/forbidden_slices.rs:47:33
143143
|
144144
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
145145

@@ -149,19 +149,19 @@ error[E0080]: could not evaluate static initializer
149149
LL | unsafe { intrinsics::offset(self, count) }
150150
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
151151
| |
152-
| pointer arithmetic failed: alloc154 has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
152+
| pointer arithmetic failed: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
153153
| inside `ptr::const_ptr::<impl *const u32>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
154154
...
155155
LL | unsafe { self.offset(count as isize) }
156156
| --------------------------- inside `ptr::const_ptr::<impl *const u32>::add` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
157157
|
158-
::: $DIR/forbidden_slices.rs:49:25
158+
::: $DIR/forbidden_slices.rs:50:25
159159
|
160160
LL | from_ptr_range(ptr..ptr.add(2))
161-
| ---------- inside `R2` at $DIR/forbidden_slices.rs:49:25
161+
| ---------- inside `R2` at $DIR/forbidden_slices.rs:50:25
162162

163163
error[E0080]: it is undefined behavior to use this value
164-
--> $DIR/forbidden_slices.rs:51:1
164+
--> $DIR/forbidden_slices.rs:52:1
165165
|
166166
LL | / pub static R4: &[u8] = unsafe {
167167
LL | |
@@ -172,11 +172,11 @@ LL | | };
172172
|
173173
= 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.
174174
= note: the raw bytes of the constant (size: 8, align: 4) {
175-
alloc159─╼ 01 00 00 00 │ ╾──╼....
175+
ALLOC_ID─╼ 01 00 00 00 │ ╾──╼....
176176
}
177177

178178
error[E0080]: it is undefined behavior to use this value
179-
--> $DIR/forbidden_slices.rs:56:1
179+
--> $DIR/forbidden_slices.rs:57:1
180180
|
181181
LL | / pub static R5: &[u8] = unsafe {
182182
LL | |
@@ -187,11 +187,11 @@ LL | | };
187187
|
188188
= 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.
189189
= note: the raw bytes of the constant (size: 8, align: 4) {
190-
alloc175─╼ 04 00 00 00 │ ╾──╼....
190+
ALLOC_ID─╼ 04 00 00 00 │ ╾──╼....
191191
}
192192

193193
error[E0080]: it is undefined behavior to use this value
194-
--> $DIR/forbidden_slices.rs:61:1
194+
--> $DIR/forbidden_slices.rs:62:1
195195
|
196196
LL | / pub static R6: &[bool] = unsafe {
197197
LL | |
@@ -202,11 +202,11 @@ LL | | };
202202
|
203203
= 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.
204204
= note: the raw bytes of the constant (size: 8, align: 4) {
205-
alloc191─╼ 04 00 00 00 │ ╾──╼....
205+
ALLOC_ID─╼ 04 00 00 00 │ ╾──╼....
206206
}
207207

208208
error[E0080]: it is undefined behavior to use this value
209-
--> $DIR/forbidden_slices.rs:66:1
209+
--> $DIR/forbidden_slices.rs:67:1
210210
|
211211
LL | / pub static R7: &[u16] = unsafe {
212212
LL | |
@@ -226,16 +226,16 @@ error[E0080]: could not evaluate static initializer
226226
LL | unsafe { intrinsics::offset(self, count) }
227227
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
228228
| |
229-
| pointer arithmetic failed: alloc230 has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
229+
| pointer arithmetic failed: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
230230
| inside `ptr::const_ptr::<impl *const u64>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
231231
...
232232
LL | unsafe { self.offset(count as isize) }
233233
| --------------------------- inside `ptr::const_ptr::<impl *const u64>::add` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
234234
|
235-
::: $DIR/forbidden_slices.rs:73:25
235+
::: $DIR/forbidden_slices.rs:74:25
236236
|
237237
LL | from_ptr_range(ptr..ptr.add(1))
238-
| ---------- inside `R8` at $DIR/forbidden_slices.rs:73:25
238+
| ---------- inside `R8` at $DIR/forbidden_slices.rs:74:25
239239

240240
error[E0080]: could not evaluate static initializer
241241
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -251,10 +251,10 @@ LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
251251
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
252252
| ------------------------------ inside `from_ptr_range::<u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
253253
|
254-
::: $DIR/forbidden_slices.rs:78:34
254+
::: $DIR/forbidden_slices.rs:79:34
255255
|
256256
LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
257-
| ----------------------------------------------- inside `R9` at $DIR/forbidden_slices.rs:78:34
257+
| ----------------------------------------------- inside `R9` at $DIR/forbidden_slices.rs:79:34
258258

259259
error[E0080]: could not evaluate static initializer
260260
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -270,10 +270,10 @@ LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
270270
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
271271
| ------------------------------ inside `from_ptr_range::<u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
272272
|
273-
::: $DIR/forbidden_slices.rs:79:35
273+
::: $DIR/forbidden_slices.rs:80:35
274274
|
275275
LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
276-
| ------------------------ inside `R10` at $DIR/forbidden_slices.rs:79:35
276+
| ------------------------ inside `R10` at $DIR/forbidden_slices.rs:80:35
277277

278278
error: aborting due to 18 previous errors
279279

0 commit comments

Comments
 (0)