Skip to content

Commit 93436d8

Browse files
committed
make error message less confusing
1 parent 9681422 commit 93436d8

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

src/librustc/mir/interpret/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ impl fmt::Debug for UnsupportedOpInfo {
485485
initializer"
486486
),
487487

488-
ReadPointerAsBytes => write!(f, "unable to turn this pointer into raw bytes",),
489-
ReadBytesAsPointer => write!(f, "unable to turn these bytes into a pointer"),
488+
ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes",),
489+
ReadBytesAsPointer => write!(f, "unable to turn bytes into a pointer"),
490490
}
491491
}
492492
}

src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr

+20-20
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ error: any use of this value will cause an error
1212
LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 };
1313
| --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
1414
| |
15-
| unable to turn this pointer into raw bytes
15+
| unable to turn pointer into raw bytes
1616
|
1717
= note: `#[deny(const_err)]` on by default
1818

@@ -22,15 +22,15 @@ error: any use of this value will cause an error
2222
LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 };
2323
| ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
2424
| |
25-
| unable to turn this pointer into raw bytes
25+
| unable to turn pointer into raw bytes
2626

2727
error: any use of this value will cause an error
2828
--> $DIR/const-pointer-values-in-various-types.rs:34:45
2929
|
3030
LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 };
3131
| ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
3232
| |
33-
| unable to turn this pointer into raw bytes
33+
| unable to turn pointer into raw bytes
3434

3535
error[E0080]: it is undefined behavior to use this value
3636
--> $DIR/const-pointer-values-in-various-types.rs:37:5
@@ -54,23 +54,23 @@ error: any use of this value will cause an error
5454
LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 };
5555
| --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
5656
| |
57-
| unable to turn this pointer into raw bytes
57+
| unable to turn pointer into raw bytes
5858

5959
error: any use of this value will cause an error
6060
--> $DIR/const-pointer-values-in-various-types.rs:46:45
6161
|
6262
LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 };
6363
| ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
6464
| |
65-
| unable to turn this pointer into raw bytes
65+
| unable to turn pointer into raw bytes
6666

6767
error: any use of this value will cause an error
6868
--> $DIR/const-pointer-values-in-various-types.rs:49:45
6969
|
7070
LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 };
7171
| ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
7272
| |
73-
| unable to turn this pointer into raw bytes
73+
| unable to turn pointer into raw bytes
7474

7575
error[E0080]: it is undefined behavior to use this value
7676
--> $DIR/const-pointer-values-in-various-types.rs:52:5
@@ -94,7 +94,7 @@ error: any use of this value will cause an error
9494
LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 };
9595
| ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
9696
| |
97-
| unable to turn this pointer into raw bytes
97+
| unable to turn pointer into raw bytes
9898

9999
error[E0080]: it is undefined behavior to use this value
100100
--> $DIR/const-pointer-values-in-various-types.rs:61:5
@@ -110,39 +110,39 @@ error: any use of this value will cause an error
110110
LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey };
111111
| ------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
112112
| |
113-
| unable to turn this pointer into raw bytes
113+
| unable to turn pointer into raw bytes
114114

115115
error: any use of this value will cause an error
116116
--> $DIR/const-pointer-values-in-various-types.rs:67:47
117117
|
118118
LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character };
119119
| ------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
120120
| |
121-
| unable to turn this pointer into raw bytes
121+
| unable to turn pointer into raw bytes
122122

123123
error: any use of this value will cause an error
124124
--> $DIR/const-pointer-values-in-various-types.rs:70:39
125125
|
126126
LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 };
127127
| ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
128128
| |
129-
| unable to turn this pointer into raw bytes
129+
| unable to turn pointer into raw bytes
130130

131131
error: any use of this value will cause an error
132132
--> $DIR/const-pointer-values-in-various-types.rs:73:41
133133
|
134134
LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 };
135135
| ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
136136
| |
137-
| unable to turn this pointer into raw bytes
137+
| unable to turn pointer into raw bytes
138138

139139
error: any use of this value will cause an error
140140
--> $DIR/const-pointer-values-in-various-types.rs:76:41
141141
|
142142
LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 };
143143
| ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
144144
| |
145-
| unable to turn this pointer into raw bytes
145+
| unable to turn pointer into raw bytes
146146

147147
error[E0080]: it is undefined behavior to use this value
148148
--> $DIR/const-pointer-values-in-various-types.rs:79:5
@@ -158,31 +158,31 @@ error: any use of this value will cause an error
158158
LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 };
159159
| --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
160160
| |
161-
| unable to turn this pointer into raw bytes
161+
| unable to turn pointer into raw bytes
162162

163163
error: any use of this value will cause an error
164164
--> $DIR/const-pointer-values-in-various-types.rs:85:39
165165
|
166166
LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 };
167167
| ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
168168
| |
169-
| unable to turn this pointer into raw bytes
169+
| unable to turn pointer into raw bytes
170170

171171
error: any use of this value will cause an error
172172
--> $DIR/const-pointer-values-in-various-types.rs:88:41
173173
|
174174
LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 };
175175
| ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
176176
| |
177-
| unable to turn this pointer into raw bytes
177+
| unable to turn pointer into raw bytes
178178

179179
error: any use of this value will cause an error
180180
--> $DIR/const-pointer-values-in-various-types.rs:91:41
181181
|
182182
LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 };
183183
| ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
184184
| |
185-
| unable to turn this pointer into raw bytes
185+
| unable to turn pointer into raw bytes
186186

187187
error[E0080]: it is undefined behavior to use this value
188188
--> $DIR/const-pointer-values-in-various-types.rs:94:5
@@ -198,15 +198,15 @@ error: any use of this value will cause an error
198198
LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 };
199199
| --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
200200
| |
201-
| unable to turn this pointer into raw bytes
201+
| unable to turn pointer into raw bytes
202202

203203
error: any use of this value will cause an error
204204
--> $DIR/const-pointer-values-in-various-types.rs:100:41
205205
|
206206
LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 };
207207
| ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
208208
| |
209-
| unable to turn this pointer into raw bytes
209+
| unable to turn pointer into raw bytes
210210

211211
error[E0080]: it is undefined behavior to use this value
212212
--> $DIR/const-pointer-values-in-various-types.rs:103:5
@@ -222,15 +222,15 @@ error: any use of this value will cause an error
222222
LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey };
223223
| --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
224224
| |
225-
| unable to turn this pointer into raw bytes
225+
| unable to turn pointer into raw bytes
226226

227227
error: any use of this value will cause an error
228228
--> $DIR/const-pointer-values-in-various-types.rs:109:43
229229
|
230230
LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character };
231231
| --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
232232
| |
233-
| unable to turn this pointer into raw bytes
233+
| unable to turn pointer into raw bytes
234234

235235
error: aborting due to 29 previous errors
236236

src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ error: any use of this value will cause an error
3030
LL | const Z2: i32 = unsafe { *(42 as *const i32) };
3131
| -------------------------^^^^^^^^^^^^^^^^^^^---
3232
| |
33-
| unable to turn these bytes into a pointer
33+
| unable to turn bytes into a pointer
3434

3535
error: any use of this value will cause an error
3636
--> $DIR/const_raw_ptr_ops.rs:17:26
3737
|
3838
LL | const Z3: i32 = unsafe { *(44 as *const i32) };
3939
| -------------------------^^^^^^^^^^^^^^^^^^^---
4040
| |
41-
| unable to turn these bytes into a pointer
41+
| unable to turn bytes into a pointer
4242

4343
error: aborting due to 5 previous errors
4444

src/test/ui/consts/offset_from_ub.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ error: any use of this value will cause an error
2626
LL | intrinsics::ptr_offset_from(self, origin)
2727
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2828
| |
29-
| unable to turn these bytes into a pointer
29+
| unable to turn bytes into a pointer
3030
| inside call to `std::ptr::const_ptr::<impl *const u8>::offset_from` at $DIR/offset_from_ub.rs:28:14
3131
|
3232
::: $DIR/offset_from_ub.rs:26:1
@@ -81,7 +81,7 @@ error: any use of this value will cause an error
8181
LL | intrinsics::ptr_offset_from(self, origin)
8282
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8383
| |
84-
| unable to turn these bytes into a pointer
84+
| unable to turn bytes into a pointer
8585
| inside call to `std::ptr::const_ptr::<impl *const u8>::offset_from` at $DIR/offset_from_ub.rs:49:14
8686
|
8787
::: $DIR/offset_from_ub.rs:45:1

src/test/ui/error-codes/E0396-fixed.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: any use of this value will cause an error
44
LL | const VALUE: u8 = unsafe { *REG_ADDR };
55
| ---------------------------^^^^^^^^^---
66
| |
7-
| unable to turn these bytes into a pointer
7+
| unable to turn bytes into a pointer
88
|
99
= note: `#[deny(const_err)]` on by default
1010

0 commit comments

Comments
 (0)