@@ -66,20 +66,20 @@ fn main() {
66
66
"attempted to instantiate uninhabited type `!`"
67
67
) ;
68
68
test_panic_msg (
69
- || mem:: uninitialized :: < [ ! ; 2 ] > ( ) ,
70
- "attempted to instantiate uninhabited type `[!; 2] `"
69
+ || mem:: zeroed :: < ! > ( ) ,
70
+ "attempted to instantiate uninhabited type `! `"
71
71
) ;
72
72
test_panic_msg (
73
- || mem :: zeroed :: < !> ( ) ,
73
+ || MaybeUninit :: < !> :: uninit ( ) . assume_init ( ) ,
74
74
"attempted to instantiate uninhabited type `!`"
75
75
) ;
76
76
test_panic_msg (
77
- || mem:: zeroed :: < [ !; 2 ] > ( ) ,
77
+ || mem:: uninitialized :: < [ !; 2 ] > ( ) ,
78
78
"attempted to instantiate uninhabited type `[!; 2]`"
79
79
) ;
80
80
test_panic_msg (
81
- || MaybeUninit :: < ! > :: uninit ( ) . assume_init ( ) ,
82
- "attempted to instantiate uninhabited type `! `"
81
+ || mem :: zeroed :: < [ ! ; 2 ] > ( ) ,
82
+ "attempted to instantiate uninhabited type `[!; 2] `"
83
83
) ;
84
84
test_panic_msg (
85
85
|| MaybeUninit :: < [ !; 2 ] > :: uninit ( ) . assume_init ( ) ,
@@ -91,20 +91,20 @@ fn main() {
91
91
"attempted to instantiate uninhabited type `Foo`"
92
92
) ;
93
93
test_panic_msg (
94
- || mem:: uninitialized :: < [ Foo ; 2 ] > ( ) ,
95
- "attempted to instantiate uninhabited type `[ Foo; 2] `"
94
+ || mem:: zeroed :: < Foo > ( ) ,
95
+ "attempted to instantiate uninhabited type `Foo`"
96
96
) ;
97
97
test_panic_msg (
98
- || mem :: zeroed :: < Foo > ( ) ,
98
+ || MaybeUninit :: < Foo > :: uninit ( ) . assume_init ( ) ,
99
99
"attempted to instantiate uninhabited type `Foo`"
100
100
) ;
101
101
test_panic_msg (
102
- || mem:: zeroed :: < [ Foo ; 2 ] > ( ) ,
102
+ || mem:: uninitialized :: < [ Foo ; 2 ] > ( ) ,
103
103
"attempted to instantiate uninhabited type `[Foo; 2]`"
104
104
) ;
105
105
test_panic_msg (
106
- || MaybeUninit :: < Foo > :: uninit ( ) . assume_init ( ) ,
107
- "attempted to instantiate uninhabited type `Foo`"
106
+ || mem :: zeroed :: < [ Foo ; 2 ] > ( ) ,
107
+ "attempted to instantiate uninhabited type `[ Foo; 2] `"
108
108
) ;
109
109
test_panic_msg (
110
110
|| MaybeUninit :: < [ Foo ; 2 ] > :: uninit ( ) . assume_init ( ) ,
@@ -116,20 +116,20 @@ fn main() {
116
116
"attempted to instantiate uninhabited type `Bar`"
117
117
) ;
118
118
test_panic_msg (
119
- || mem:: uninitialized :: < [ Bar ; 4 ] > ( ) ,
120
- "attempted to instantiate uninhabited type `[ Bar; 4] `"
119
+ || mem:: zeroed :: < Bar > ( ) ,
120
+ "attempted to instantiate uninhabited type `Bar`"
121
121
) ;
122
122
test_panic_msg (
123
- || mem :: zeroed :: < Bar > ( ) ,
123
+ || MaybeUninit :: < Bar > :: uninit ( ) . assume_init ( ) ,
124
124
"attempted to instantiate uninhabited type `Bar`"
125
125
) ;
126
126
test_panic_msg (
127
- || mem:: zeroed :: < [ Bar ; 4 ] > ( ) ,
127
+ || mem:: uninitialized :: < [ Bar ; 4 ] > ( ) ,
128
128
"attempted to instantiate uninhabited type `[Bar; 4]`"
129
129
) ;
130
130
test_panic_msg (
131
- || MaybeUninit :: < Bar > :: uninit ( ) . assume_init ( ) ,
132
- "attempted to instantiate uninhabited type `Bar`"
131
+ || mem :: zeroed :: < [ Bar ; 4 ] > ( ) ,
132
+ "attempted to instantiate uninhabited type `[ Bar; 4] `"
133
133
) ;
134
134
test_panic_msg (
135
135
|| MaybeUninit :: < [ Bar ; 4 ] > :: uninit ( ) . assume_init ( ) ,
@@ -141,14 +141,14 @@ fn main() {
141
141
|| mem:: uninitialized :: < fn ( ) > ( ) ,
142
142
"attempted to leave type `fn()` uninitialized, which is invalid"
143
143
) ;
144
- test_panic_msg (
145
- || mem:: uninitialized :: < [ fn ( ) ; 2 ] > ( ) ,
146
- "attempted to leave type `[fn(); 2]` uninitialized, which is invalid"
147
- ) ;
148
144
test_panic_msg (
149
145
|| mem:: zeroed :: < fn ( ) > ( ) ,
150
146
"attempted to zero-initialize type `fn()`, which is invalid"
151
147
) ;
148
+ test_panic_msg (
149
+ || mem:: uninitialized :: < [ fn ( ) ; 2 ] > ( ) ,
150
+ "attempted to leave type `[fn(); 2]` uninitialized, which is invalid"
151
+ ) ;
152
152
test_panic_msg (
153
153
|| mem:: zeroed :: < [ fn ( ) ; 2 ] > ( ) ,
154
154
"attempted to zero-initialize type `[fn(); 2]`, which is invalid"
@@ -158,17 +158,19 @@ fn main() {
158
158
|| mem:: uninitialized :: < * const dyn Send > ( ) ,
159
159
"attempted to leave type `*const dyn std::marker::Send` uninitialized, which is invalid"
160
160
) ;
161
- test_panic_msg (
162
- || mem:: uninitialized :: < [ * const dyn Send ; 2 ] > ( ) ,
163
- "attempted to leave type `[*const dyn std::marker::Send; 2]` uninitialized, which is invalid"
164
- ) ;
165
161
test_panic_msg (
166
162
|| mem:: zeroed :: < * const dyn Send > ( ) ,
167
163
"attempted to zero-initialize type `*const dyn std::marker::Send`, which is invalid"
168
164
) ;
165
+ test_panic_msg (
166
+ || mem:: uninitialized :: < [ * const dyn Send ; 2 ] > ( ) ,
167
+ "attempted to leave type `[*const dyn std::marker::Send; 2]` uninitialized, \
168
+ which is invalid"
169
+ ) ;
169
170
test_panic_msg (
170
171
|| mem:: zeroed :: < [ * const dyn Send ; 2 ] > ( ) ,
171
- "attempted to zero-initialize type `[*const dyn std::marker::Send; 2]`, which is invalid"
172
+ "attempted to zero-initialize type `[*const dyn std::marker::Send; 2]`, \
173
+ which is invalid"
172
174
) ;
173
175
174
176
/* FIXME(#66151) we conservatively do not error here yet.
@@ -199,13 +201,13 @@ fn main() {
199
201
which is invalid"
200
202
) ;
201
203
test_panic_msg (
202
- || mem:: uninitialized :: < [ ( NonNull < u32 > , u32 , u32 ) ; 2 ] > ( ) ,
203
- "attempted to leave type `[ (std::ptr::NonNull<u32>, u32, u32); 2]` uninitialized , \
204
+ || mem:: zeroed :: < ( NonNull < u32 > , u32 , u32 ) > ( ) ,
205
+ "attempted to zero-initialize type `(std::ptr::NonNull<u32>, u32, u32)` , \
204
206
which is invalid"
205
207
) ;
206
208
test_panic_msg (
207
- || mem:: zeroed :: < ( NonNull < u32 > , u32 , u32 ) > ( ) ,
208
- "attempted to zero-initialize type `(std::ptr::NonNull<u32>, u32, u32)` , \
209
+ || mem:: uninitialized :: < [ ( NonNull < u32 > , u32 , u32 ) ; 2 ] > ( ) ,
210
+ "attempted to leave type `[ (std::ptr::NonNull<u32>, u32, u32); 2]` uninitialized , \
209
211
which is invalid"
210
212
) ;
211
213
test_panic_msg (
@@ -220,13 +222,13 @@ fn main() {
220
222
which is invalid"
221
223
) ;
222
224
test_panic_msg (
223
- || mem:: uninitialized :: < [ OneVariant_NonZero ; 2 ] > ( ) ,
224
- "attempted to leave type `[ OneVariant_NonZero; 2]` uninitialized , \
225
+ || mem:: zeroed :: < OneVariant_NonZero > ( ) ,
226
+ "attempted to zero-initialize type `OneVariant_NonZero` , \
225
227
which is invalid"
226
228
) ;
227
229
test_panic_msg (
228
- || mem:: zeroed :: < OneVariant_NonZero > ( ) ,
229
- "attempted to zero-initialize type `OneVariant_NonZero` , \
230
+ || mem:: uninitialized :: < [ OneVariant_NonZero ; 2 ] > ( ) ,
231
+ "attempted to leave type `[ OneVariant_NonZero; 2]` uninitialized , \
230
232
which is invalid"
231
233
) ;
232
234
test_panic_msg (
@@ -241,13 +243,13 @@ fn main() {
241
243
which is invalid"
242
244
) ;
243
245
test_panic_msg (
244
- || mem:: uninitialized :: < [ NoNullVariant ; 2 ] > ( ) ,
245
- "attempted to leave type `[ NoNullVariant; 2]` uninitialized , \
246
+ || mem:: zeroed :: < NoNullVariant > ( ) ,
247
+ "attempted to zero-initialize type `NoNullVariant` , \
246
248
which is invalid"
247
249
) ;
248
250
test_panic_msg (
249
- || mem:: zeroed :: < NoNullVariant > ( ) ,
250
- "attempted to zero-initialize type `NoNullVariant` , \
251
+ || mem:: uninitialized :: < [ NoNullVariant ; 2 ] > ( ) ,
252
+ "attempted to leave type `[ NoNullVariant; 2]` uninitialized , \
251
253
which is invalid"
252
254
) ;
253
255
test_panic_msg (
@@ -261,10 +263,6 @@ fn main() {
261
263
|| mem:: uninitialized :: < bool > ( ) ,
262
264
"attempted to leave type `bool` uninitialized, which is invalid"
263
265
) ;
264
- test_panic_msg (
265
- || mem:: uninitialized :: < [ bool ; 2 ] > ( ) ,
266
- "attempted to leave type `[bool; 2]` uninitialized, which is invalid"
267
- ) ;
268
266
test_panic_msg (
269
267
|| mem:: uninitialized :: < LR > ( ) ,
270
268
"attempted to leave type `LR` uninitialized, which is invalid"
@@ -273,6 +271,19 @@ fn main() {
273
271
|| mem:: uninitialized :: < ManuallyDrop < LR > > ( ) ,
274
272
"attempted to leave type `std::mem::ManuallyDrop<LR>` uninitialized, which is invalid"
275
273
) ;
274
+ test_panic_msg (
275
+ || mem:: uninitialized :: < [ bool ; 2 ] > ( ) ,
276
+ "attempted to leave type `[bool; 2]` uninitialized, which is invalid"
277
+ ) ;
278
+ test_panic_msg (
279
+ || mem:: uninitialized :: < [ LR ; 2 ] > ( ) ,
280
+ "attempted to leave type `[LR; 2]` uninitialized, which is invalid"
281
+ ) ;
282
+ test_panic_msg (
283
+ || mem:: uninitialized :: < [ ManuallyDrop < LR > ; 2 ] > ( ) ,
284
+ "attempted to leave type `[std::mem::ManuallyDrop<LR>; 2]` uninitialized, \
285
+ which is invalid"
286
+ ) ;
276
287
277
288
// Some things that should work.
278
289
let _val = mem:: zeroed :: < bool > ( ) ;
0 commit comments