1 error: the type `&T` does not permit zero-initialization
2 --> $DIR/uninitialized-zeroed.rs:40:32
4 LL | let _val: &'static T = mem::zeroed();
7 | this code causes undefined behavior when executed
8 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
10 note: the lint level is defined here
11 --> $DIR/uninitialized-zeroed.rs:6:9
13 LL | #![deny(invalid_value)]
15 = note: references must be non-null
17 error: the type `&T` does not permit being left uninitialized
18 --> $DIR/uninitialized-zeroed.rs:41:32
20 LL | let _val: &'static T = mem::uninitialized();
21 | ^^^^^^^^^^^^^^^^^^^^
23 | this code causes undefined behavior when executed
24 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
26 = note: references must be non-null
28 error: the type `Wrap<&T>` does not permit zero-initialization
29 --> $DIR/uninitialized-zeroed.rs:43:38
31 LL | let _val: Wrap<&'static T> = mem::zeroed();
34 | this code causes undefined behavior when executed
35 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
37 note: references must be non-null (in this struct field)
38 --> $DIR/uninitialized-zeroed.rs:17:18
40 LL | struct Wrap<T> { wrapped: T }
43 error: the type `Wrap<&T>` does not permit being left uninitialized
44 --> $DIR/uninitialized-zeroed.rs:44:38
46 LL | let _val: Wrap<&'static T> = mem::uninitialized();
47 | ^^^^^^^^^^^^^^^^^^^^
49 | this code causes undefined behavior when executed
50 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
52 note: references must be non-null (in this struct field)
53 --> $DIR/uninitialized-zeroed.rs:17:18
55 LL | struct Wrap<T> { wrapped: T }
58 error: the type `!` does not permit zero-initialization
59 --> $DIR/uninitialized-zeroed.rs:51:23
61 LL | let _val: ! = mem::zeroed();
64 | this code causes undefined behavior when executed
65 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
67 = note: the `!` type has no valid value
69 error: the type `!` does not permit being left uninitialized
70 --> $DIR/uninitialized-zeroed.rs:52:23
72 LL | let _val: ! = mem::uninitialized();
73 | ^^^^^^^^^^^^^^^^^^^^
75 | this code causes undefined behavior when executed
76 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
78 = note: the `!` type has no valid value
80 error: the type `(i32, !)` does not permit zero-initialization
81 --> $DIR/uninitialized-zeroed.rs:54:30
83 LL | let _val: (i32, !) = mem::zeroed();
86 | this code causes undefined behavior when executed
87 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
89 = note: the `!` type has no valid value
91 error: the type `(i32, !)` does not permit being left uninitialized
92 --> $DIR/uninitialized-zeroed.rs:55:30
94 LL | let _val: (i32, !) = mem::uninitialized();
95 | ^^^^^^^^^^^^^^^^^^^^
97 | this code causes undefined behavior when executed
98 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
100 = note: the `!` type has no valid value
102 error: the type `Void` does not permit zero-initialization
103 --> $DIR/uninitialized-zeroed.rs:57:26
105 LL | let _val: Void = mem::zeroed();
108 | this code causes undefined behavior when executed
109 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
111 = note: enums with no variants have no valid value
113 error: the type `Void` does not permit being left uninitialized
114 --> $DIR/uninitialized-zeroed.rs:58:26
116 LL | let _val: Void = mem::uninitialized();
117 | ^^^^^^^^^^^^^^^^^^^^
119 | this code causes undefined behavior when executed
120 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
122 = note: enums with no variants have no valid value
124 error: the type `&i32` does not permit zero-initialization
125 --> $DIR/uninitialized-zeroed.rs:60:34
127 LL | let _val: &'static i32 = mem::zeroed();
130 | this code causes undefined behavior when executed
131 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
133 = note: references must be non-null
135 error: the type `&i32` does not permit being left uninitialized
136 --> $DIR/uninitialized-zeroed.rs:61:34
138 LL | let _val: &'static i32 = mem::uninitialized();
139 | ^^^^^^^^^^^^^^^^^^^^
141 | this code causes undefined behavior when executed
142 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
144 = note: references must be non-null
146 error: the type `Ref` does not permit zero-initialization
147 --> $DIR/uninitialized-zeroed.rs:63:25
149 LL | let _val: Ref = mem::zeroed();
152 | this code causes undefined behavior when executed
153 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
155 note: references must be non-null (in this struct field)
156 --> $DIR/uninitialized-zeroed.rs:14:12
158 LL | struct Ref(&'static i32);
161 error: the type `Ref` does not permit being left uninitialized
162 --> $DIR/uninitialized-zeroed.rs:64:25
164 LL | let _val: Ref = mem::uninitialized();
165 | ^^^^^^^^^^^^^^^^^^^^
167 | this code causes undefined behavior when executed
168 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
170 note: references must be non-null (in this struct field)
171 --> $DIR/uninitialized-zeroed.rs:14:12
173 LL | struct Ref(&'static i32);
176 error: the type `fn()` does not permit zero-initialization
177 --> $DIR/uninitialized-zeroed.rs:66:26
179 LL | let _val: fn() = mem::zeroed();
182 | this code causes undefined behavior when executed
183 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
185 = note: function pointers must be non-null
187 error: the type `fn()` does not permit being left uninitialized
188 --> $DIR/uninitialized-zeroed.rs:67:26
190 LL | let _val: fn() = mem::uninitialized();
191 | ^^^^^^^^^^^^^^^^^^^^
193 | this code causes undefined behavior when executed
194 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
196 = note: function pointers must be non-null
198 error: the type `Wrap<fn()>` does not permit zero-initialization
199 --> $DIR/uninitialized-zeroed.rs:69:32
201 LL | let _val: Wrap<fn()> = mem::zeroed();
204 | this code causes undefined behavior when executed
205 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
207 note: function pointers must be non-null (in this struct field)
208 --> $DIR/uninitialized-zeroed.rs:17:18
210 LL | struct Wrap<T> { wrapped: T }
213 error: the type `Wrap<fn()>` does not permit being left uninitialized
214 --> $DIR/uninitialized-zeroed.rs:70:32
216 LL | let _val: Wrap<fn()> = mem::uninitialized();
217 | ^^^^^^^^^^^^^^^^^^^^
219 | this code causes undefined behavior when executed
220 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
222 note: function pointers must be non-null (in this struct field)
223 --> $DIR/uninitialized-zeroed.rs:17:18
225 LL | struct Wrap<T> { wrapped: T }
228 error: the type `WrapEnum<fn()>` does not permit zero-initialization
229 --> $DIR/uninitialized-zeroed.rs:72:36
231 LL | let _val: WrapEnum<fn()> = mem::zeroed();
234 | this code causes undefined behavior when executed
235 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
237 note: function pointers must be non-null (in this enum field)
238 --> $DIR/uninitialized-zeroed.rs:18:28
240 LL | enum WrapEnum<T> { Wrapped(T) }
243 error: the type `WrapEnum<fn()>` does not permit being left uninitialized
244 --> $DIR/uninitialized-zeroed.rs:73:36
246 LL | let _val: WrapEnum<fn()> = mem::uninitialized();
247 | ^^^^^^^^^^^^^^^^^^^^
249 | this code causes undefined behavior when executed
250 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
252 note: function pointers must be non-null (in this enum field)
253 --> $DIR/uninitialized-zeroed.rs:18:28
255 LL | enum WrapEnum<T> { Wrapped(T) }
258 error: the type `Wrap<(RefPair, i32)>` does not permit zero-initialization
259 --> $DIR/uninitialized-zeroed.rs:75:42
261 LL | let _val: Wrap<(RefPair, i32)> = mem::zeroed();
264 | this code causes undefined behavior when executed
265 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
267 note: references must be non-null (in this struct field)
268 --> $DIR/uninitialized-zeroed.rs:15:16
270 LL | struct RefPair((&'static i32, i32));
271 | ^^^^^^^^^^^^^^^^^^^
273 error: the type `Wrap<(RefPair, i32)>` does not permit being left uninitialized
274 --> $DIR/uninitialized-zeroed.rs:76:42
276 LL | let _val: Wrap<(RefPair, i32)> = mem::uninitialized();
277 | ^^^^^^^^^^^^^^^^^^^^
279 | this code causes undefined behavior when executed
280 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
282 note: references must be non-null (in this struct field)
283 --> $DIR/uninitialized-zeroed.rs:15:16
285 LL | struct RefPair((&'static i32, i32));
286 | ^^^^^^^^^^^^^^^^^^^
288 error: the type `NonNull<i32>` does not permit zero-initialization
289 --> $DIR/uninitialized-zeroed.rs:78:34
291 LL | let _val: NonNull<i32> = mem::zeroed();
294 | this code causes undefined behavior when executed
295 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
297 = note: `std::ptr::NonNull<i32>` must be non-null
299 error: the type `NonNull<i32>` does not permit being left uninitialized
300 --> $DIR/uninitialized-zeroed.rs:79:34
302 LL | let _val: NonNull<i32> = mem::uninitialized();
303 | ^^^^^^^^^^^^^^^^^^^^
305 | this code causes undefined behavior when executed
306 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
308 = note: `std::ptr::NonNull<i32>` must be non-null
310 error: the type `*const dyn Send` does not permit zero-initialization
311 --> $DIR/uninitialized-zeroed.rs:81:37
313 LL | let _val: *const dyn Send = mem::zeroed();
316 | this code causes undefined behavior when executed
317 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
319 = note: the vtable of a wide raw pointer must be non-null
321 error: the type `*const dyn Send` does not permit being left uninitialized
322 --> $DIR/uninitialized-zeroed.rs:82:37
324 LL | let _val: *const dyn Send = mem::uninitialized();
325 | ^^^^^^^^^^^^^^^^^^^^
327 | this code causes undefined behavior when executed
328 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
330 = note: the vtable of a wide raw pointer must be non-null
332 error: the type `bool` does not permit being left uninitialized
333 --> $DIR/uninitialized-zeroed.rs:86:26
335 LL | let _val: bool = mem::uninitialized();
336 | ^^^^^^^^^^^^^^^^^^^^
338 | this code causes undefined behavior when executed
339 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
341 = note: booleans must be either `true` or `false`
343 error: the type `Wrap<char>` does not permit being left uninitialized
344 --> $DIR/uninitialized-zeroed.rs:89:32
346 LL | let _val: Wrap<char> = mem::uninitialized();
347 | ^^^^^^^^^^^^^^^^^^^^
349 | this code causes undefined behavior when executed
350 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
352 note: characters must be a valid Unicode codepoint (in this struct field)
353 --> $DIR/uninitialized-zeroed.rs:17:18
355 LL | struct Wrap<T> { wrapped: T }
358 error: the type `NonBig` does not permit being left uninitialized
359 --> $DIR/uninitialized-zeroed.rs:92:28
361 LL | let _val: NonBig = mem::uninitialized();
362 | ^^^^^^^^^^^^^^^^^^^^
364 | this code causes undefined behavior when executed
365 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
367 = note: `NonBig` must be initialized inside its custom valid range
369 error: the type `Fruit` does not permit being left uninitialized
370 --> $DIR/uninitialized-zeroed.rs:95:27
372 LL | let _val: Fruit = mem::uninitialized();
373 | ^^^^^^^^^^^^^^^^^^^^
375 | this code causes undefined behavior when executed
376 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
378 note: enums have to be initialized to a variant
379 --> $DIR/uninitialized-zeroed.rs:26:1
387 error: the type `&i32` does not permit zero-initialization
388 --> $DIR/uninitialized-zeroed.rs:98:34
390 LL | let _val: &'static i32 = mem::transmute(0usize);
391 | ^^^^^^^^^^^^^^^^^^^^^^
393 | this code causes undefined behavior when executed
394 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
396 = note: references must be non-null
398 error: the type `&[i32]` does not permit zero-initialization
399 --> $DIR/uninitialized-zeroed.rs:99:36
401 LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize));
402 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
404 | this code causes undefined behavior when executed
405 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
407 = note: references must be non-null
409 error: the type `NonZeroU32` does not permit zero-initialization
410 --> $DIR/uninitialized-zeroed.rs:100:32
412 LL | let _val: NonZeroU32 = mem::transmute(0);
415 | this code causes undefined behavior when executed
416 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
418 = note: `std::num::NonZeroU32` must be non-null
420 error: the type `NonNull<i32>` does not permit zero-initialization
421 --> $DIR/uninitialized-zeroed.rs:103:34
423 LL | let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init();
424 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
426 | this code causes undefined behavior when executed
427 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
429 = note: `std::ptr::NonNull<i32>` must be non-null
431 error: the type `NonNull<i32>` does not permit being left uninitialized
432 --> $DIR/uninitialized-zeroed.rs:104:34
434 LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init();
435 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
437 | this code causes undefined behavior when executed
438 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
440 = note: `std::ptr::NonNull<i32>` must be non-null
442 error: the type `bool` does not permit being left uninitialized
443 --> $DIR/uninitialized-zeroed.rs:105:26
445 LL | let _val: bool = MaybeUninit::uninit().assume_init();
446 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
448 | this code causes undefined behavior when executed
449 | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
451 = note: booleans must be either `true` or `false`
453 error: aborting due to 36 previous errors