@@ -5,7 +5,7 @@ LL | let _val: &'static T = mem::zeroed();
55 | ^^^^^^^^^^^^^
66 | |
77 | this code causes undefined behavior when executed
8- | help: use `MaybeUninit<T>` instead
8+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
99 |
1010note: lint level defined here
1111 --> $DIR/uninitialized-zeroed.rs:7:9
@@ -21,7 +21,7 @@ LL | let _val: &'static T = mem::uninitialized();
2121 | ^^^^^^^^^^^^^^^^^^^^
2222 | |
2323 | this code causes undefined behavior when executed
24- | help: use `MaybeUninit<T>` instead
24+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
2525 |
2626 = note: References must be non-null
2727
@@ -32,7 +32,7 @@ LL | let _val: Wrap<&'static T> = mem::zeroed();
3232 | ^^^^^^^^^^^^^
3333 | |
3434 | this code causes undefined behavior when executed
35- | help: use `MaybeUninit<T>` instead
35+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
3636 |
3737note: References must be non-null (in this struct field)
3838 --> $DIR/uninitialized-zeroed.rs:18:18
@@ -47,7 +47,7 @@ LL | let _val: Wrap<&'static T> = mem::uninitialized();
4747 | ^^^^^^^^^^^^^^^^^^^^
4848 | |
4949 | this code causes undefined behavior when executed
50- | help: use `MaybeUninit<T>` instead
50+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
5151 |
5252note: References must be non-null (in this struct field)
5353 --> $DIR/uninitialized-zeroed.rs:18:18
@@ -62,7 +62,7 @@ LL | let _val: ! = mem::zeroed();
6262 | ^^^^^^^^^^^^^
6363 | |
6464 | this code causes undefined behavior when executed
65- | help: use `MaybeUninit<T>` instead
65+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
6666 |
6767 = note: The never type (`!`) has no valid value
6868
@@ -73,7 +73,7 @@ LL | let _val: ! = mem::uninitialized();
7373 | ^^^^^^^^^^^^^^^^^^^^
7474 | |
7575 | this code causes undefined behavior when executed
76- | help: use `MaybeUninit<T>` instead
76+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
7777 |
7878 = note: The never type (`!`) has no valid value
7979
@@ -84,7 +84,7 @@ LL | let _val: (i32, !) = mem::zeroed();
8484 | ^^^^^^^^^^^^^
8585 | |
8686 | this code causes undefined behavior when executed
87- | help: use `MaybeUninit<T>` instead
87+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
8888 |
8989 = note: The never type (`!`) has no valid value
9090
@@ -95,7 +95,7 @@ LL | let _val: (i32, !) = mem::uninitialized();
9595 | ^^^^^^^^^^^^^^^^^^^^
9696 | |
9797 | this code causes undefined behavior when executed
98- | help: use `MaybeUninit<T>` instead
98+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
9999 |
100100 = note: The never type (`!`) has no valid value
101101
@@ -106,7 +106,7 @@ LL | let _val: Void = mem::zeroed();
106106 | ^^^^^^^^^^^^^
107107 | |
108108 | this code causes undefined behavior when executed
109- | help: use `MaybeUninit<T>` instead
109+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
110110 |
111111 = note: 0-variant enums have no valid value
112112
@@ -117,7 +117,7 @@ LL | let _val: Void = mem::uninitialized();
117117 | ^^^^^^^^^^^^^^^^^^^^
118118 | |
119119 | this code causes undefined behavior when executed
120- | help: use `MaybeUninit<T>` instead
120+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
121121 |
122122 = note: 0-variant enums have no valid value
123123
@@ -128,7 +128,7 @@ LL | let _val: &'static i32 = mem::zeroed();
128128 | ^^^^^^^^^^^^^
129129 | |
130130 | this code causes undefined behavior when executed
131- | help: use `MaybeUninit<T>` instead
131+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
132132 |
133133 = note: References must be non-null
134134
@@ -139,7 +139,7 @@ LL | let _val: &'static i32 = mem::uninitialized();
139139 | ^^^^^^^^^^^^^^^^^^^^
140140 | |
141141 | this code causes undefined behavior when executed
142- | help: use `MaybeUninit<T>` instead
142+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
143143 |
144144 = note: References must be non-null
145145
@@ -150,7 +150,7 @@ LL | let _val: Ref = mem::zeroed();
150150 | ^^^^^^^^^^^^^
151151 | |
152152 | this code causes undefined behavior when executed
153- | help: use `MaybeUninit<T>` instead
153+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
154154 |
155155note: References must be non-null (in this struct field)
156156 --> $DIR/uninitialized-zeroed.rs:15:12
@@ -165,7 +165,7 @@ LL | let _val: Ref = mem::uninitialized();
165165 | ^^^^^^^^^^^^^^^^^^^^
166166 | |
167167 | this code causes undefined behavior when executed
168- | help: use `MaybeUninit<T>` instead
168+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
169169 |
170170note: References must be non-null (in this struct field)
171171 --> $DIR/uninitialized-zeroed.rs:15:12
@@ -180,7 +180,7 @@ LL | let _val: fn() = mem::zeroed();
180180 | ^^^^^^^^^^^^^
181181 | |
182182 | this code causes undefined behavior when executed
183- | help: use `MaybeUninit<T>` instead
183+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
184184 |
185185 = note: Function pointers must be non-null
186186
@@ -191,7 +191,7 @@ LL | let _val: fn() = mem::uninitialized();
191191 | ^^^^^^^^^^^^^^^^^^^^
192192 | |
193193 | this code causes undefined behavior when executed
194- | help: use `MaybeUninit<T>` instead
194+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
195195 |
196196 = note: Function pointers must be non-null
197197
@@ -202,7 +202,7 @@ LL | let _val: Wrap<fn()> = mem::zeroed();
202202 | ^^^^^^^^^^^^^
203203 | |
204204 | this code causes undefined behavior when executed
205- | help: use `MaybeUninit<T>` instead
205+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
206206 |
207207note: Function pointers must be non-null (in this struct field)
208208 --> $DIR/uninitialized-zeroed.rs:18:18
@@ -217,7 +217,7 @@ LL | let _val: Wrap<fn()> = mem::uninitialized();
217217 | ^^^^^^^^^^^^^^^^^^^^
218218 | |
219219 | this code causes undefined behavior when executed
220- | help: use `MaybeUninit<T>` instead
220+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
221221 |
222222note: Function pointers must be non-null (in this struct field)
223223 --> $DIR/uninitialized-zeroed.rs:18:18
@@ -232,7 +232,7 @@ LL | let _val: WrapEnum<fn()> = mem::zeroed();
232232 | ^^^^^^^^^^^^^
233233 | |
234234 | this code causes undefined behavior when executed
235- | help: use `MaybeUninit<T>` instead
235+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
236236 |
237237note: Function pointers must be non-null (in this enum field)
238238 --> $DIR/uninitialized-zeroed.rs:19:28
@@ -247,7 +247,7 @@ LL | let _val: WrapEnum<fn()> = mem::uninitialized();
247247 | ^^^^^^^^^^^^^^^^^^^^
248248 | |
249249 | this code causes undefined behavior when executed
250- | help: use `MaybeUninit<T>` instead
250+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
251251 |
252252note: Function pointers must be non-null (in this enum field)
253253 --> $DIR/uninitialized-zeroed.rs:19:28
@@ -262,7 +262,7 @@ LL | let _val: Wrap<(RefPair, i32)> = mem::zeroed();
262262 | ^^^^^^^^^^^^^
263263 | |
264264 | this code causes undefined behavior when executed
265- | help: use `MaybeUninit<T>` instead
265+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
266266 |
267267note: References must be non-null (in this struct field)
268268 --> $DIR/uninitialized-zeroed.rs:16:16
@@ -277,7 +277,7 @@ LL | let _val: Wrap<(RefPair, i32)> = mem::uninitialized();
277277 | ^^^^^^^^^^^^^^^^^^^^
278278 | |
279279 | this code causes undefined behavior when executed
280- | help: use `MaybeUninit<T>` instead
280+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
281281 |
282282note: References must be non-null (in this struct field)
283283 --> $DIR/uninitialized-zeroed.rs:16:16
@@ -292,7 +292,7 @@ LL | let _val: NonNull<i32> = mem::zeroed();
292292 | ^^^^^^^^^^^^^
293293 | |
294294 | this code causes undefined behavior when executed
295- | help: use `MaybeUninit<T>` instead
295+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
296296 |
297297 = note: std::ptr::NonNull<i32> must be non-null
298298
@@ -303,7 +303,7 @@ LL | let _val: NonNull<i32> = mem::uninitialized();
303303 | ^^^^^^^^^^^^^^^^^^^^
304304 | |
305305 | this code causes undefined behavior when executed
306- | help: use `MaybeUninit<T>` instead
306+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
307307 |
308308 = note: std::ptr::NonNull<i32> must be non-null
309309
@@ -314,7 +314,7 @@ LL | let _val: *const dyn Send = mem::zeroed();
314314 | ^^^^^^^^^^^^^
315315 | |
316316 | this code causes undefined behavior when executed
317- | help: use `MaybeUninit<T>` instead
317+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
318318 |
319319 = note: The vtable of a wide raw pointer must be non-null
320320
@@ -325,7 +325,7 @@ LL | let _val: *const dyn Send = mem::uninitialized();
325325 | ^^^^^^^^^^^^^^^^^^^^
326326 | |
327327 | this code causes undefined behavior when executed
328- | help: use `MaybeUninit<T>` instead
328+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
329329 |
330330 = note: The vtable of a wide raw pointer must be non-null
331331
@@ -336,7 +336,7 @@ LL | let _val: bool = mem::uninitialized();
336336 | ^^^^^^^^^^^^^^^^^^^^
337337 | |
338338 | this code causes undefined behavior when executed
339- | help: use `MaybeUninit<T>` instead
339+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
340340 |
341341 = note: Booleans must be `true` or `false`
342342
@@ -347,7 +347,7 @@ LL | let _val: Wrap<char> = mem::uninitialized();
347347 | ^^^^^^^^^^^^^^^^^^^^
348348 | |
349349 | this code causes undefined behavior when executed
350- | help: use `MaybeUninit<T>` instead
350+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
351351 |
352352note: Characters must be a valid unicode codepoint (in this struct field)
353353 --> $DIR/uninitialized-zeroed.rs:18:18
@@ -362,7 +362,7 @@ LL | let _val: NonBig = mem::uninitialized();
362362 | ^^^^^^^^^^^^^^^^^^^^
363363 | |
364364 | this code causes undefined behavior when executed
365- | help: use `MaybeUninit<T>` instead
365+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
366366 |
367367 = note: NonBig must be initialized inside its custom valid range
368368
@@ -373,7 +373,7 @@ LL | let _val: &'static i32 = mem::transmute(0usize);
373373 | ^^^^^^^^^^^^^^^^^^^^^^
374374 | |
375375 | this code causes undefined behavior when executed
376- | help: use `MaybeUninit<T>` instead
376+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
377377 |
378378 = note: References must be non-null
379379
@@ -384,7 +384,7 @@ LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize));
384384 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
385385 | |
386386 | this code causes undefined behavior when executed
387- | help: use `MaybeUninit<T>` instead
387+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
388388 |
389389 = note: References must be non-null
390390
@@ -395,7 +395,7 @@ LL | let _val: NonZeroU32 = mem::transmute(0);
395395 | ^^^^^^^^^^^^^^^^^
396396 | |
397397 | this code causes undefined behavior when executed
398- | help: use `MaybeUninit<T>` instead
398+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
399399 |
400400 = note: std::num::NonZeroU32 must be non-null
401401
@@ -406,7 +406,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init();
406406 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
407407 | |
408408 | this code causes undefined behavior when executed
409- | help: use `MaybeUninit<T>` instead
409+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
410410 |
411411 = note: std::ptr::NonNull<i32> must be non-null
412412
@@ -417,7 +417,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init();
417417 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
418418 | |
419419 | this code causes undefined behavior when executed
420- | help: use `MaybeUninit<T>` instead
420+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
421421 |
422422 = note: std::ptr::NonNull<i32> must be non-null
423423
@@ -428,7 +428,7 @@ LL | let _val: bool = MaybeUninit::uninit().assume_init();
428428 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
429429 | |
430430 | this code causes undefined behavior when executed
431- | help: use `MaybeUninit<T>` instead
431+ | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
432432 |
433433 = note: Booleans must be `true` or `false`
434434
0 commit comments