Skip to content

Commit ee7d038

Browse files
committed
Fix src/test/ui/const-ptr/forbidden_slices.rs test.
The number of line drawing characters depends on the number of digits in the allocation number. This removes the characters to avoid spurious failures.
1 parent 95f1fe4 commit ee7d038

File tree

3 files changed

+73
-72
lines changed

3 files changed

+73
-72
lines changed

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

+36-36
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 a dangling pointer (it has no provenance)
88
| inside `std::slice::from_raw_parts::<u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
99
|
10-
::: $DIR/forbidden_slices.rs:18:34
10+
::: $DIR/forbidden_slices.rs:19:34
1111
|
1212
LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
13-
| ------------------------------ inside `S0` at $DIR/forbidden_slices.rs:18:34
13+
| ------------------------------ inside `S0` at $DIR/forbidden_slices.rs:19:34
1414

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

2929
error[E0080]: could not evaluate static initializer
3030
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
@@ -35,54 +35,54 @@ LL | &*ptr::slice_from_raw_parts(data, len)
3535
| 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:22:34
38+
::: $DIR/forbidden_slices.rs:23:34
3939
|
4040
LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
41-
| ---------------------- inside `S2` at $DIR/forbidden_slices.rs:22:34
41+
| ---------------------- inside `S2` at $DIR/forbidden_slices.rs:23:34
4242

4343
error[E0080]: it is undefined behavior to use this value
44-
--> $DIR/forbidden_slices.rs:25:1
44+
--> $DIR/forbidden_slices.rs:26:1
4545
|
4646
LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
4747
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value 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-
ALLOC_ID╼ 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:27:1
55+
--> $DIR/forbidden_slices.rs:28:1
5656
|
5757
LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) };
5858
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
5959
|
6060
= help: this code performed an operation that depends on the underlying bytes representing a pointer
6161
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
6262
= note: the raw bytes of the constant (size: 8, align: 4) {
63-
ALLOC_ID╼ 04 00 00 00 │ ╾──╼....
63+
╾ALLOC_ID╼ 04 00 00 00 │ ╾╼....
6464
}
6565

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

7777
error[E0080]: it is undefined behavior to use this value
78-
--> $DIR/forbidden_slices.rs:32:1
78+
--> $DIR/forbidden_slices.rs:33:1
7979
|
8080
LL | pub static S7: &[u16] = unsafe {
8181
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
8282
|
8383
= 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.
8484
= note: the raw bytes of the constant (size: 8, align: 4) {
85-
A_ID+0x1╼ 04 00 00 00 │ ╾──╼....
85+
╾A_ID+0x1╼ 04 00 00 00 │ ╾╼....
8686
}
8787

8888
error[E0080]: could not evaluate static initializer
@@ -94,10 +94,10 @@ LL | &*ptr::slice_from_raw_parts(data, len)
9494
| dereferencing pointer failed: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
9595
| inside `std::slice::from_raw_parts::<u64>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
9696
|
97-
::: $DIR/forbidden_slices.rs:43:5
97+
::: $DIR/forbidden_slices.rs:44:5
9898
|
9999
LL | from_raw_parts(ptr, 1)
100-
| ---------------------- inside `S8` at $DIR/forbidden_slices.rs:43:5
100+
| ---------------------- inside `S8` at $DIR/forbidden_slices.rs:44:5
101101

102102
error[E0080]: could not evaluate static initializer
103103
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -113,10 +113,10 @@ LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
113113
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
114114
| ------------------------------ inside `from_ptr_range::<u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
115115
|
116-
::: $DIR/forbidden_slices.rs:46:34
116+
::: $DIR/forbidden_slices.rs:47:34
117117
|
118118
LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
119-
| ---------------------------------------- inside `R0` at $DIR/forbidden_slices.rs:46:34
119+
| ---------------------------------------- inside `R0` at $DIR/forbidden_slices.rs:47:34
120120

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

@@ -151,54 +151,54 @@ LL | unsafe { intrinsics::offset(self, count) }
151151
LL | unsafe { self.offset(count as isize) }
152152
| --------------------------- inside `ptr::const_ptr::<impl *const u32>::add` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
153153
|
154-
::: $DIR/forbidden_slices.rs:50:25
154+
::: $DIR/forbidden_slices.rs:51:25
155155
|
156156
LL | from_ptr_range(ptr..ptr.add(2))
157-
| ---------- inside `R2` at $DIR/forbidden_slices.rs:50:25
157+
| ---------- inside `R2` at $DIR/forbidden_slices.rs:51:25
158158

159159
error[E0080]: it is undefined behavior to use this value
160-
--> $DIR/forbidden_slices.rs:52:1
160+
--> $DIR/forbidden_slices.rs:53:1
161161
|
162162
LL | pub static R4: &[u8] = unsafe {
163163
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized bytes
164164
|
165165
= 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.
166166
= note: the raw bytes of the constant (size: 8, align: 4) {
167-
╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼....
167+
╾ALLOC_ID╼ 01 00 00 00 │ ╾╼....
168168
}
169169

170170
error[E0080]: it is undefined behavior to use this value
171-
--> $DIR/forbidden_slices.rs:57:1
171+
--> $DIR/forbidden_slices.rs:58:1
172172
|
173173
LL | pub static R5: &[u8] = unsafe {
174174
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
175175
|
176176
= help: this code performed an operation that depends on the underlying bytes representing a pointer
177177
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
178178
= note: the raw bytes of the constant (size: 8, align: 4) {
179-
╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼....
179+
╾ALLOC_ID╼ 04 00 00 00 │ ╾╼....
180180
}
181181

182182
error[E0080]: it is undefined behavior to use this value
183-
--> $DIR/forbidden_slices.rs:62:1
183+
--> $DIR/forbidden_slices.rs:63:1
184184
|
185185
LL | pub static R6: &[bool] = unsafe {
186186
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
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-
╾ALLOC_ID╼ 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:67:1
194+
--> $DIR/forbidden_slices.rs:68:1
195195
|
196196
LL | pub static R7: &[u16] = unsafe {
197197
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
198198
|
199199
= 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.
200200
= note: the raw bytes of the constant (size: 8, align: 4) {
201-
╾A_ID+0x1╼ 04 00 00 00 │ ╾──╼....
201+
╾A_ID+0x1╼ 04 00 00 00 │ ╾╼....
202202
}
203203

204204
error[E0080]: could not evaluate static initializer
@@ -213,10 +213,10 @@ LL | unsafe { intrinsics::offset(self, count) }
213213
LL | unsafe { self.offset(count as isize) }
214214
| --------------------------- inside `ptr::const_ptr::<impl *const u64>::add` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
215215
|
216-
::: $DIR/forbidden_slices.rs:74:25
216+
::: $DIR/forbidden_slices.rs:75:25
217217
|
218218
LL | from_ptr_range(ptr..ptr.add(1))
219-
| ---------- inside `R8` at $DIR/forbidden_slices.rs:74:25
219+
| ---------- inside `R8` at $DIR/forbidden_slices.rs:75:25
220220

221221
error[E0080]: could not evaluate static initializer
222222
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -232,10 +232,10 @@ LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
232232
LL | unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
233233
| ------------------------------ inside `from_ptr_range::<u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
234234
|
235-
::: $DIR/forbidden_slices.rs:79:34
235+
::: $DIR/forbidden_slices.rs:80:34
236236
|
237237
LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
238-
| ----------------------------------------------- inside `R9` at $DIR/forbidden_slices.rs:79:34
238+
| ----------------------------------------------- inside `R9` at $DIR/forbidden_slices.rs:80:34
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:80:35
254+
::: $DIR/forbidden_slices.rs:81:35
255255
|
256256
LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
257-
| ------------------------ inside `R10` at $DIR/forbidden_slices.rs:80:35
257+
| ------------------------ inside `R10` at $DIR/forbidden_slices.rs:81:35
258258

259259
error: aborting due to 18 previous errors
260260

0 commit comments

Comments
 (0)