1
1
error[E0080]: it is undefined behavior to use this value
2
- --> $DIR/ub-wide-ptr.rs:38 :1
2
+ --> $DIR/ub-wide-ptr.rs:39 :1
3
3
|
4
4
LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
5
5
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
@@ -10,7 +10,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
10
10
}
11
11
12
12
error[E0080]: it is undefined behavior to use this value
13
- --> $DIR/ub-wide-ptr.rs:40 :1
13
+ --> $DIR/ub-wide-ptr.rs:41 :1
14
14
|
15
15
LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
16
16
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object
@@ -21,7 +21,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us
21
21
}
22
22
23
23
error[E0080]: evaluation of constant value failed
24
- --> $DIR/ub-wide-ptr.rs:43 :1
24
+ --> $DIR/ub-wide-ptr.rs:44 :1
25
25
|
26
26
LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
27
27
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -30,7 +30,7 @@ LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
30
30
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
31
31
32
32
error[E0080]: evaluation of constant value failed
33
- --> $DIR/ub-wide-ptr.rs:46 :1
33
+ --> $DIR/ub-wide-ptr.rs:47 :1
34
34
|
35
35
LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
36
36
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -39,7 +39,7 @@ LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
39
39
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
40
40
41
41
error[E0080]: it is undefined behavior to use this value
42
- --> $DIR/ub-wide-ptr.rs:48 :1
42
+ --> $DIR/ub-wide-ptr.rs:49 :1
43
43
|
44
44
LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
45
45
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
@@ -50,7 +50,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize:
50
50
}
51
51
52
52
error[E0080]: it is undefined behavior to use this value
53
- --> $DIR/ub-wide-ptr.rs:52 :1
53
+ --> $DIR/ub-wide-ptr.rs:53 :1
54
54
|
55
55
LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
56
56
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string
@@ -61,7 +61,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:
61
61
}
62
62
63
63
error[E0080]: it is undefined behavior to use this value
64
- --> $DIR/ub-wide-ptr.rs:55 :1
64
+ --> $DIR/ub-wide-ptr.rs:56 :1
65
65
|
66
66
LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
67
67
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string
@@ -72,13 +72,13 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni
72
72
}
73
73
74
74
error[E0080]: evaluation of constant value failed
75
- --> $DIR/ub-wide-ptr.rs:62 :1
75
+ --> $DIR/ub-wide-ptr.rs:63 :1
76
76
|
77
77
LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe {
78
78
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
79
79
80
80
error[E0080]: it is undefined behavior to use this value
81
- --> $DIR/ub-wide-ptr.rs:69 :1
81
+ --> $DIR/ub-wide-ptr.rs:70 :1
82
82
|
83
83
LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
84
84
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
@@ -89,7 +89,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
89
89
}
90
90
91
91
error[E0080]: it is undefined behavior to use this value
92
- --> $DIR/ub-wide-ptr.rs:72 :1
92
+ --> $DIR/ub-wide-ptr.rs:73 :1
93
93
|
94
94
LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) };
95
95
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
@@ -100,7 +100,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is
100
100
}
101
101
102
102
error[E0080]: evaluation of constant value failed
103
- --> $DIR/ub-wide-ptr.rs:75 :1
103
+ --> $DIR/ub-wide-ptr.rs:76 :1
104
104
|
105
105
LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
106
106
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -109,7 +109,7 @@ LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
109
109
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
110
110
111
111
error[E0080]: it is undefined behavior to use this value
112
- --> $DIR/ub-wide-ptr.rs:78 :1
112
+ --> $DIR/ub-wide-ptr.rs:79 :1
113
113
|
114
114
LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
115
115
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation)
@@ -120,7 +120,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us
120
120
}
121
121
122
122
error[E0080]: evaluation of constant value failed
123
- --> $DIR/ub-wide-ptr.rs:81 :1
123
+ --> $DIR/ub-wide-ptr.rs:82 :1
124
124
|
125
125
LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) };
126
126
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -129,7 +129,7 @@ LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)
129
129
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
130
130
131
131
error[E0080]: it is undefined behavior to use this value
132
- --> $DIR/ub-wide-ptr.rs:85 :1
132
+ --> $DIR/ub-wide-ptr.rs:86 :1
133
133
|
134
134
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
135
135
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean
@@ -140,13 +140,13 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
140
140
}
141
141
142
142
note: erroneous constant encountered
143
- --> $DIR/ub-wide-ptr.rs:85 :40
143
+ --> $DIR/ub-wide-ptr.rs:86 :40
144
144
|
145
145
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
146
146
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
147
147
148
148
error[E0080]: it is undefined behavior to use this value
149
- --> $DIR/ub-wide-ptr.rs:92 :1
149
+ --> $DIR/ub-wide-ptr.rs:93 :1
150
150
|
151
151
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
152
152
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean
@@ -157,13 +157,13 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3
157
157
}
158
158
159
159
note: erroneous constant encountered
160
- --> $DIR/ub-wide-ptr.rs:92 :42
160
+ --> $DIR/ub-wide-ptr.rs:93 :42
161
161
|
162
162
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
163
163
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
164
164
165
165
error[E0080]: it is undefined behavior to use this value
166
- --> $DIR/ub-wide-ptr.rs:96 :1
166
+ --> $DIR/ub-wide-ptr.rs:97 :1
167
167
|
168
168
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
169
169
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean
@@ -174,19 +174,19 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran
174
174
}
175
175
176
176
note: erroneous constant encountered
177
- --> $DIR/ub-wide-ptr.rs:96 :42
177
+ --> $DIR/ub-wide-ptr.rs:97 :42
178
178
|
179
179
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
180
180
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
181
181
182
182
error[E0080]: evaluation of constant value failed
183
- --> $DIR/ub-wide-ptr.rs:104 :1
183
+ --> $DIR/ub-wide-ptr.rs:105 :1
184
184
|
185
185
LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
186
186
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
187
187
188
188
error[E0080]: it is undefined behavior to use this value
189
- --> $DIR/ub-wide-ptr.rs:113 :1
189
+ --> $DIR/ub-wide-ptr.rs:114 :1
190
190
|
191
191
LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
192
192
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC12<imm>, but expected a vtable pointer
@@ -197,7 +197,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((
197
197
}
198
198
199
199
error[E0080]: it is undefined behavior to use this value
200
- --> $DIR/ub-wide-ptr.rs:117 :1
200
+ --> $DIR/ub-wide-ptr.rs:118 :1
201
201
|
202
202
LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
203
203
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC14<imm>, but expected a vtable pointer
@@ -208,7 +208,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((
208
208
}
209
209
210
210
error[E0080]: it is undefined behavior to use this value
211
- --> $DIR/ub-wide-ptr.rs:121 :1
211
+ --> $DIR/ub-wide-ptr.rs:122 :1
212
212
|
213
213
LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
214
214
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer
@@ -219,7 +219,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u
219
219
}
220
220
221
221
error[E0080]: it is undefined behavior to use this value
222
- --> $DIR/ub-wide-ptr.rs:124 :1
222
+ --> $DIR/ub-wide-ptr.rs:125 :1
223
223
|
224
224
LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
225
225
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC17<imm>, but expected a vtable pointer
@@ -230,7 +230,7 @@ LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92
230
230
}
231
231
232
232
error[E0080]: it is undefined behavior to use this value
233
- --> $DIR/ub-wide-ptr.rs:127 :1
233
+ --> $DIR/ub-wide-ptr.rs:128 :1
234
234
|
235
235
LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
236
236
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC19<imm>, but expected a vtable pointer
@@ -241,7 +241,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92
241
241
}
242
242
243
243
error[E0080]: it is undefined behavior to use this value
244
- --> $DIR/ub-wide-ptr.rs:130 :1
244
+ --> $DIR/ub-wide-ptr.rs:131 :1
245
245
|
246
246
LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
247
247
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC21<imm>, but expected a vtable pointer
@@ -252,7 +252,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u
252
252
}
253
253
254
254
error[E0080]: it is undefined behavior to use this value
255
- --> $DIR/ub-wide-ptr.rs:133 :1
255
+ --> $DIR/ub-wide-ptr.rs:134 :1
256
256
|
257
257
LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
258
258
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC23<imm>, but expected a vtable pointer
@@ -263,7 +263,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans
263
263
}
264
264
265
265
error[E0080]: it is undefined behavior to use this value
266
- --> $DIR/ub-wide-ptr.rs:138 :1
266
+ --> $DIR/ub-wide-ptr.rs:139 :1
267
267
|
268
268
LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
269
269
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean
@@ -274,7 +274,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_,
274
274
}
275
275
276
276
error[E0080]: it is undefined behavior to use this value
277
- --> $DIR/ub-wide-ptr.rs:143 :1
277
+ --> $DIR/ub-wide-ptr.rs:144 :1
278
278
|
279
279
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
280
280
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer
@@ -285,7 +285,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute
285
285
}
286
286
287
287
error[E0080]: it is undefined behavior to use this value
288
- --> $DIR/ub-wide-ptr.rs:145 :1
288
+ --> $DIR/ub-wide-ptr.rs:146 :1
289
289
|
290
290
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
291
291
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC28<imm>, but expected a vtable pointer
@@ -296,7 +296,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm
296
296
}
297
297
298
298
error[E0080]: it is undefined behavior to use this value
299
- --> $DIR/ub-wide-ptr.rs:150 :1
299
+ --> $DIR/ub-wide-ptr.rs:153 :1
300
300
|
301
301
LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe {
302
302
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer
@@ -307,7 +307,7 @@ LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe
307
307
}
308
308
309
309
error[E0080]: it is undefined behavior to use this value
310
- --> $DIR/ub-wide-ptr.rs:154 :1
310
+ --> $DIR/ub-wide-ptr.rs:157 :1
311
311
|
312
312
LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe {
313
313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC31<imm>, but expected a vtable pointer
0 commit comments