]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/uninitialized-zeroed.stderr
Update const_forget.rs
[rust.git] / src / test / ui / lint / uninitialized-zeroed.stderr
1 error: the type `&'static T` does not permit zero-initialization
2   --> $DIR/uninitialized-zeroed.rs:29:32
3    |
4 LL |         let _val: &'static T = mem::zeroed();
5    |                                ^^^^^^^^^^^^^
6    |                                |
7    |                                this code causes undefined behavior when executed
8    |                                help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
9    |
10 note: the lint level is defined here
11   --> $DIR/uninitialized-zeroed.rs:7:9
12    |
13 LL | #![deny(invalid_value)]
14    |         ^^^^^^^^^^^^^
15    = note: references must be non-null
16
17 error: the type `&'static T` does not permit being left uninitialized
18   --> $DIR/uninitialized-zeroed.rs:30:32
19    |
20 LL |         let _val: &'static T = mem::uninitialized();
21    |                                ^^^^^^^^^^^^^^^^^^^^
22    |                                |
23    |                                this code causes undefined behavior when executed
24    |                                help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
25    |
26    = note: references must be non-null
27
28 error: the type `Wrap<&'static T>` does not permit zero-initialization
29   --> $DIR/uninitialized-zeroed.rs:32:38
30    |
31 LL |         let _val: Wrap<&'static T> = mem::zeroed();
32    |                                      ^^^^^^^^^^^^^
33    |                                      |
34    |                                      this code causes undefined behavior when executed
35    |                                      help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
36    |
37 note: references must be non-null (in this struct field)
38   --> $DIR/uninitialized-zeroed.rs:18:18
39    |
40 LL | struct Wrap<T> { wrapped: T }
41    |                  ^^^^^^^^^^
42
43 error: the type `Wrap<&'static T>` does not permit being left uninitialized
44   --> $DIR/uninitialized-zeroed.rs:33:38
45    |
46 LL |         let _val: Wrap<&'static T> = mem::uninitialized();
47    |                                      ^^^^^^^^^^^^^^^^^^^^
48    |                                      |
49    |                                      this code causes undefined behavior when executed
50    |                                      help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
51    |
52 note: references must be non-null (in this struct field)
53   --> $DIR/uninitialized-zeroed.rs:18:18
54    |
55 LL | struct Wrap<T> { wrapped: T }
56    |                  ^^^^^^^^^^
57
58 error: the type `!` does not permit zero-initialization
59   --> $DIR/uninitialized-zeroed.rs:40:23
60    |
61 LL |         let _val: ! = mem::zeroed();
62    |                       ^^^^^^^^^^^^^
63    |                       |
64    |                       this code causes undefined behavior when executed
65    |                       help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
66    |
67    = note: the `!` type has no valid value
68
69 error: the type `!` does not permit being left uninitialized
70   --> $DIR/uninitialized-zeroed.rs:41:23
71    |
72 LL |         let _val: ! = mem::uninitialized();
73    |                       ^^^^^^^^^^^^^^^^^^^^
74    |                       |
75    |                       this code causes undefined behavior when executed
76    |                       help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
77    |
78    = note: the `!` type has no valid value
79
80 error: the type `(i32, !)` does not permit zero-initialization
81   --> $DIR/uninitialized-zeroed.rs:43:30
82    |
83 LL |         let _val: (i32, !) = mem::zeroed();
84    |                              ^^^^^^^^^^^^^
85    |                              |
86    |                              this code causes undefined behavior when executed
87    |                              help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
88    |
89    = note: the `!` type has no valid value
90
91 error: the type `(i32, !)` does not permit being left uninitialized
92   --> $DIR/uninitialized-zeroed.rs:44:30
93    |
94 LL |         let _val: (i32, !) = mem::uninitialized();
95    |                              ^^^^^^^^^^^^^^^^^^^^
96    |                              |
97    |                              this code causes undefined behavior when executed
98    |                              help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
99    |
100    = note: the `!` type has no valid value
101
102 error: the type `Void` does not permit zero-initialization
103   --> $DIR/uninitialized-zeroed.rs:46:26
104    |
105 LL |         let _val: Void = mem::zeroed();
106    |                          ^^^^^^^^^^^^^
107    |                          |
108    |                          this code causes undefined behavior when executed
109    |                          help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
110    |
111    = note: enums with no variants have no valid value
112
113 error: the type `Void` does not permit being left uninitialized
114   --> $DIR/uninitialized-zeroed.rs:47:26
115    |
116 LL |         let _val: Void = mem::uninitialized();
117    |                          ^^^^^^^^^^^^^^^^^^^^
118    |                          |
119    |                          this code causes undefined behavior when executed
120    |                          help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
121    |
122    = note: enums with no variants have no valid value
123
124 error: the type `&'static i32` does not permit zero-initialization
125   --> $DIR/uninitialized-zeroed.rs:49:34
126    |
127 LL |         let _val: &'static i32 = mem::zeroed();
128    |                                  ^^^^^^^^^^^^^
129    |                                  |
130    |                                  this code causes undefined behavior when executed
131    |                                  help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
132    |
133    = note: references must be non-null
134
135 error: the type `&'static i32` does not permit being left uninitialized
136   --> $DIR/uninitialized-zeroed.rs:50:34
137    |
138 LL |         let _val: &'static i32 = mem::uninitialized();
139    |                                  ^^^^^^^^^^^^^^^^^^^^
140    |                                  |
141    |                                  this code causes undefined behavior when executed
142    |                                  help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
143    |
144    = note: references must be non-null
145
146 error: the type `Ref` does not permit zero-initialization
147   --> $DIR/uninitialized-zeroed.rs:52:25
148    |
149 LL |         let _val: Ref = mem::zeroed();
150    |                         ^^^^^^^^^^^^^
151    |                         |
152    |                         this code causes undefined behavior when executed
153    |                         help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
154    |
155 note: references must be non-null (in this struct field)
156   --> $DIR/uninitialized-zeroed.rs:15:12
157    |
158 LL | struct Ref(&'static i32);
159    |            ^^^^^^^^^^^^
160
161 error: the type `Ref` does not permit being left uninitialized
162   --> $DIR/uninitialized-zeroed.rs:53:25
163    |
164 LL |         let _val: Ref = mem::uninitialized();
165    |                         ^^^^^^^^^^^^^^^^^^^^
166    |                         |
167    |                         this code causes undefined behavior when executed
168    |                         help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
169    |
170 note: references must be non-null (in this struct field)
171   --> $DIR/uninitialized-zeroed.rs:15:12
172    |
173 LL | struct Ref(&'static i32);
174    |            ^^^^^^^^^^^^
175
176 error: the type `fn()` does not permit zero-initialization
177   --> $DIR/uninitialized-zeroed.rs:55:26
178    |
179 LL |         let _val: fn() = mem::zeroed();
180    |                          ^^^^^^^^^^^^^
181    |                          |
182    |                          this code causes undefined behavior when executed
183    |                          help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
184    |
185    = note: function pointers must be non-null
186
187 error: the type `fn()` does not permit being left uninitialized
188   --> $DIR/uninitialized-zeroed.rs:56:26
189    |
190 LL |         let _val: fn() = mem::uninitialized();
191    |                          ^^^^^^^^^^^^^^^^^^^^
192    |                          |
193    |                          this code causes undefined behavior when executed
194    |                          help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
195    |
196    = note: function pointers must be non-null
197
198 error: the type `Wrap<fn()>` does not permit zero-initialization
199   --> $DIR/uninitialized-zeroed.rs:58:32
200    |
201 LL |         let _val: Wrap<fn()> = mem::zeroed();
202    |                                ^^^^^^^^^^^^^
203    |                                |
204    |                                this code causes undefined behavior when executed
205    |                                help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
206    |
207 note: function pointers must be non-null (in this struct field)
208   --> $DIR/uninitialized-zeroed.rs:18:18
209    |
210 LL | struct Wrap<T> { wrapped: T }
211    |                  ^^^^^^^^^^
212
213 error: the type `Wrap<fn()>` does not permit being left uninitialized
214   --> $DIR/uninitialized-zeroed.rs:59:32
215    |
216 LL |         let _val: Wrap<fn()> = mem::uninitialized();
217    |                                ^^^^^^^^^^^^^^^^^^^^
218    |                                |
219    |                                this code causes undefined behavior when executed
220    |                                help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
221    |
222 note: function pointers must be non-null (in this struct field)
223   --> $DIR/uninitialized-zeroed.rs:18:18
224    |
225 LL | struct Wrap<T> { wrapped: T }
226    |                  ^^^^^^^^^^
227
228 error: the type `WrapEnum<fn()>` does not permit zero-initialization
229   --> $DIR/uninitialized-zeroed.rs:61:36
230    |
231 LL |         let _val: WrapEnum<fn()> = mem::zeroed();
232    |                                    ^^^^^^^^^^^^^
233    |                                    |
234    |                                    this code causes undefined behavior when executed
235    |                                    help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
236    |
237 note: function pointers must be non-null (in this enum field)
238   --> $DIR/uninitialized-zeroed.rs:19:28
239    |
240 LL | enum WrapEnum<T> { Wrapped(T) }
241    |                            ^
242
243 error: the type `WrapEnum<fn()>` does not permit being left uninitialized
244   --> $DIR/uninitialized-zeroed.rs:62:36
245    |
246 LL |         let _val: WrapEnum<fn()> = mem::uninitialized();
247    |                                    ^^^^^^^^^^^^^^^^^^^^
248    |                                    |
249    |                                    this code causes undefined behavior when executed
250    |                                    help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
251    |
252 note: function pointers must be non-null (in this enum field)
253   --> $DIR/uninitialized-zeroed.rs:19:28
254    |
255 LL | enum WrapEnum<T> { Wrapped(T) }
256    |                            ^
257
258 error: the type `Wrap<(RefPair, i32)>` does not permit zero-initialization
259   --> $DIR/uninitialized-zeroed.rs:64:42
260    |
261 LL |         let _val: Wrap<(RefPair, i32)> = mem::zeroed();
262    |                                          ^^^^^^^^^^^^^
263    |                                          |
264    |                                          this code causes undefined behavior when executed
265    |                                          help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
266    |
267 note: references must be non-null (in this struct field)
268   --> $DIR/uninitialized-zeroed.rs:16:16
269    |
270 LL | struct RefPair((&'static i32, i32));
271    |                ^^^^^^^^^^^^^^^^^^^
272
273 error: the type `Wrap<(RefPair, i32)>` does not permit being left uninitialized
274   --> $DIR/uninitialized-zeroed.rs:65:42
275    |
276 LL |         let _val: Wrap<(RefPair, i32)> = mem::uninitialized();
277    |                                          ^^^^^^^^^^^^^^^^^^^^
278    |                                          |
279    |                                          this code causes undefined behavior when executed
280    |                                          help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
281    |
282 note: references must be non-null (in this struct field)
283   --> $DIR/uninitialized-zeroed.rs:16:16
284    |
285 LL | struct RefPair((&'static i32, i32));
286    |                ^^^^^^^^^^^^^^^^^^^
287
288 error: the type `std::ptr::NonNull<i32>` does not permit zero-initialization
289   --> $DIR/uninitialized-zeroed.rs:67:34
290    |
291 LL |         let _val: NonNull<i32> = mem::zeroed();
292    |                                  ^^^^^^^^^^^^^
293    |                                  |
294    |                                  this code causes undefined behavior when executed
295    |                                  help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
296    |
297    = note: `std::ptr::NonNull<i32>` must be non-null
298
299 error: the type `std::ptr::NonNull<i32>` does not permit being left uninitialized
300   --> $DIR/uninitialized-zeroed.rs:68:34
301    |
302 LL |         let _val: NonNull<i32> = mem::uninitialized();
303    |                                  ^^^^^^^^^^^^^^^^^^^^
304    |                                  |
305    |                                  this code causes undefined behavior when executed
306    |                                  help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
307    |
308    = note: `std::ptr::NonNull<i32>` must be non-null
309
310 error: the type `*const dyn std::marker::Send` does not permit zero-initialization
311   --> $DIR/uninitialized-zeroed.rs:70:37
312    |
313 LL |         let _val: *const dyn Send = mem::zeroed();
314    |                                     ^^^^^^^^^^^^^
315    |                                     |
316    |                                     this code causes undefined behavior when executed
317    |                                     help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
318    |
319    = note: the vtable of a wide raw pointer must be non-null
320
321 error: the type `*const dyn std::marker::Send` does not permit being left uninitialized
322   --> $DIR/uninitialized-zeroed.rs:71:37
323    |
324 LL |         let _val: *const dyn Send = mem::uninitialized();
325    |                                     ^^^^^^^^^^^^^^^^^^^^
326    |                                     |
327    |                                     this code causes undefined behavior when executed
328    |                                     help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
329    |
330    = note: the vtable of a wide raw pointer must be non-null
331
332 error: the type `bool` does not permit being left uninitialized
333   --> $DIR/uninitialized-zeroed.rs:75:26
334    |
335 LL |         let _val: bool = mem::uninitialized();
336    |                          ^^^^^^^^^^^^^^^^^^^^
337    |                          |
338    |                          this code causes undefined behavior when executed
339    |                          help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
340    |
341    = note: booleans must be either `true` or `false`
342
343 error: the type `Wrap<char>` does not permit being left uninitialized
344   --> $DIR/uninitialized-zeroed.rs:78:32
345    |
346 LL |         let _val: Wrap<char> = mem::uninitialized();
347    |                                ^^^^^^^^^^^^^^^^^^^^
348    |                                |
349    |                                this code causes undefined behavior when executed
350    |                                help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
351    |
352 note: characters must be a valid Unicode codepoint (in this struct field)
353   --> $DIR/uninitialized-zeroed.rs:18:18
354    |
355 LL | struct Wrap<T> { wrapped: T }
356    |                  ^^^^^^^^^^
357
358 error: the type `NonBig` does not permit being left uninitialized
359   --> $DIR/uninitialized-zeroed.rs:81:28
360    |
361 LL |         let _val: NonBig = mem::uninitialized();
362    |                            ^^^^^^^^^^^^^^^^^^^^
363    |                            |
364    |                            this code causes undefined behavior when executed
365    |                            help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
366    |
367    = note: `NonBig` must be initialized inside its custom valid range
368
369 error: the type `&'static i32` does not permit zero-initialization
370   --> $DIR/uninitialized-zeroed.rs:84:34
371    |
372 LL |         let _val: &'static i32 = mem::transmute(0usize);
373    |                                  ^^^^^^^^^^^^^^^^^^^^^^
374    |                                  |
375    |                                  this code causes undefined behavior when executed
376    |                                  help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
377    |
378    = note: references must be non-null
379
380 error: the type `&'static [i32]` does not permit zero-initialization
381   --> $DIR/uninitialized-zeroed.rs:85:36
382    |
383 LL |         let _val: &'static [i32] = mem::transmute((0usize, 0usize));
384    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
385    |                                    |
386    |                                    this code causes undefined behavior when executed
387    |                                    help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
388    |
389    = note: references must be non-null
390
391 error: the type `std::num::NonZeroU32` does not permit zero-initialization
392   --> $DIR/uninitialized-zeroed.rs:86:32
393    |
394 LL |         let _val: NonZeroU32 = mem::transmute(0);
395    |                                ^^^^^^^^^^^^^^^^^
396    |                                |
397    |                                this code causes undefined behavior when executed
398    |                                help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
399    |
400    = note: `std::num::NonZeroU32` must be non-null
401
402 error: the type `std::ptr::NonNull<i32>` does not permit zero-initialization
403   --> $DIR/uninitialized-zeroed.rs:89:34
404    |
405 LL |         let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init();
406    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
407    |                                  |
408    |                                  this code causes undefined behavior when executed
409    |                                  help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
410    |
411    = note: `std::ptr::NonNull<i32>` must be non-null
412
413 error: the type `std::ptr::NonNull<i32>` does not permit being left uninitialized
414   --> $DIR/uninitialized-zeroed.rs:90:34
415    |
416 LL |         let _val: NonNull<i32> = MaybeUninit::uninit().assume_init();
417    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
418    |                                  |
419    |                                  this code causes undefined behavior when executed
420    |                                  help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
421    |
422    = note: `std::ptr::NonNull<i32>` must be non-null
423
424 error: the type `bool` does not permit being left uninitialized
425   --> $DIR/uninitialized-zeroed.rs:91:26
426    |
427 LL |         let _val: bool = MaybeUninit::uninit().assume_init();
428    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
429    |                          |
430    |                          this code causes undefined behavior when executed
431    |                          help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
432    |
433    = note: booleans must be either `true` or `false`
434
435 error: aborting due to 35 previous errors
436