Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 96a2e65

Browse files
committedSep 8, 2022
Add more tests, add docs for is_mem_uninit field
1 parent dc4b6a9 commit 96a2e65

File tree

3 files changed

+380
-30
lines changed

3 files changed

+380
-30
lines changed
 

‎compiler/rustc_lint/src/builtin.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -2366,7 +2366,14 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
23662366
#[derive(Debug, Copy, Clone, PartialEq)]
23672367
enum InitKind {
23682368
Zeroed,
2369-
Uninit { is_mem_uninit: bool },
2369+
/// `is_mem_uninit` is true *only* if this is a call to `mem::uninitialized()`, not if
2370+
/// this is a `MaybeUninit::uninit().assume_init()`.
2371+
///
2372+
/// This lets us avoid duplicate errors being shown, for code that matches the
2373+
/// mem_uninitialized FCW.
2374+
Uninit {
2375+
is_mem_uninit: bool,
2376+
},
23702377
}
23712378

23722379
impl InitKind {

‎src/test/ui/intrinsics/mem-uninitialized-future-compat.rs

+39
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ struct UninitStruct {
99
b: char,
1010
}
1111

12+
enum OneVariant {
13+
Hello,
14+
}
15+
16+
enum TwoVariant {
17+
Hello,
18+
Goodbye,
19+
}
20+
21+
enum OneVariantWith<T> {
22+
Hello(T),
23+
}
24+
1225
unsafe fn unknown_type<T, const N: usize>() {
1326
std::mem::uninitialized::<T>();
1427
//~^ ERROR the type `T` is generic, and might not permit being left uninitialized
@@ -22,6 +35,12 @@ unsafe fn unknown_type<T, const N: usize>() {
2235
std::mem::uninitialized::<[UninitStruct; N]>();
2336
//~^ ERROR the type `[UninitStruct; N]` is generic, and might not permit being left uninitialized
2437

38+
std::mem::uninitialized::<Result<T, !>>();
39+
//~^ ERROR the type `std::result::Result<T, !>` does not permit being left uninitialized
40+
41+
std::mem::uninitialized::<OneVariantWith<T>>();
42+
//~^ ERROR the type `OneVariantWith<T>` is generic, and might not permit being left uninitialized
43+
2544
std::mem::uninitialized::<[T; 0]>();
2645
std::mem::uninitialized::<[char; 0]>();
2746
}
@@ -58,10 +77,30 @@ fn main() {
5877
std::mem::uninitialized::<(u32, char)>();
5978
//~^ ERROR the type `(u32, char)` does not permit being left uninitialized
6079

80+
std::mem::uninitialized::<TwoVariant>();
81+
//~^ ERROR the type `TwoVariant` does not permit being left uninitialized
82+
83+
std::mem::uninitialized::<Result<!, !>>();
84+
//~^ ERROR the type `std::result::Result<!, !>` does not permit being left uninitialized
85+
86+
std::mem::uninitialized::<Result<!, u32>>();
87+
//~^ ERROR the type `std::result::Result<!, u32>` does not permit being left uninitialized
88+
89+
std::mem::uninitialized::<Option<!>>();
90+
//~^ ERROR the type `std::option::Option<!>` does not permit being left uninitialized
91+
92+
std::mem::uninitialized::<OneVariantWith<char>>();
93+
//~^ ERROR the type `OneVariantWith<char>` does not permit being left uninitialized
94+
95+
std::mem::uninitialized::<OneVariantWith<!>>();
96+
//~^ ERROR the type `OneVariantWith<!>` does not permit being left uninitialized
97+
6198
std::mem::uninitialized::<MaybeUninit<Box<u32>>>();
6299
std::mem::uninitialized::<usize>();
63100
std::mem::uninitialized::<f32>();
64101
std::mem::uninitialized::<*const u8>();
65102
std::mem::uninitialized::<[u8; 64]>();
103+
std::mem::uninitialized::<OneVariant>();
104+
std::mem::uninitialized::<OneVariantWith<u32>>();
66105
}
67106
}

‎src/test/ui/intrinsics/mem-uninitialized-future-compat.stderr

+333-29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: the type `T` is generic, and might not permit being left uninitialized
2-
--> $DIR/mem-uninitialized-future-compat.rs:13:5
2+
--> $DIR/mem-uninitialized-future-compat.rs:26:5
33
|
44
LL | std::mem::uninitialized::<T>();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -16,7 +16,7 @@ LL | #![deny(mem_uninitialized)]
1616
= note: type might not be allowed to be left uninitialized
1717

1818
error: the type `[T; N]` is generic, and might not permit being left uninitialized
19-
--> $DIR/mem-uninitialized-future-compat.rs:16:5
19+
--> $DIR/mem-uninitialized-future-compat.rs:29:5
2020
|
2121
LL | std::mem::uninitialized::<[T; N]>();
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -28,7 +28,7 @@ LL | std::mem::uninitialized::<[T; N]>();
2828
= note: type might not be allowed to be left uninitialized
2929

3030
error: the type `[char; N]` is generic, and might not permit being left uninitialized
31-
--> $DIR/mem-uninitialized-future-compat.rs:19:5
31+
--> $DIR/mem-uninitialized-future-compat.rs:32:5
3232
|
3333
LL | std::mem::uninitialized::<[char; N]>();
3434
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -40,7 +40,7 @@ LL | std::mem::uninitialized::<[char; N]>();
4040
= note: characters must be a valid Unicode codepoint
4141

4242
error: the type `[UninitStruct; N]` is generic, and might not permit being left uninitialized
43-
--> $DIR/mem-uninitialized-future-compat.rs:22:5
43+
--> $DIR/mem-uninitialized-future-compat.rs:35:5
4444
|
4545
LL | std::mem::uninitialized::<[UninitStruct; N]>();
4646
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -55,8 +55,40 @@ note: characters must be a valid Unicode codepoint (in this struct field)
5555
LL | b: char,
5656
| ^^^^^^^
5757

58+
error: the type `std::result::Result<T, !>` does not permit being left uninitialized
59+
--> $DIR/mem-uninitialized-future-compat.rs:38:5
60+
|
61+
LL | std::mem::uninitialized::<Result<T, !>>();
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: for more information, see FIXME: fill this in
68+
note: enums have to be initialized to a variant
69+
--> $SRC_DIR/core/src/result.rs:LL:COL
70+
|
71+
LL | pub enum Result<T, E> {
72+
| ^^^^^^^^^^^^^^^^^^^^^
73+
74+
error: the type `OneVariantWith<T>` is generic, and might not permit being left uninitialized
75+
--> $DIR/mem-uninitialized-future-compat.rs:41:5
76+
|
77+
LL | std::mem::uninitialized::<OneVariantWith<T>>();
78+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79+
| |
80+
| this code causes undefined behavior when executed
81+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
82+
|
83+
= note: for more information, see FIXME: fill this in
84+
note: type might not be allowed to be left uninitialized (in this enum field)
85+
--> $DIR/mem-uninitialized-future-compat.rs:22:11
86+
|
87+
LL | Hello(T),
88+
| ^
89+
5890
error: the type `&u32` does not permit being left uninitialized
59-
--> $DIR/mem-uninitialized-future-compat.rs:31:9
91+
--> $DIR/mem-uninitialized-future-compat.rs:50:9
6092
|
6193
LL | std::mem::uninitialized::<&'static u32>();
6294
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -68,7 +100,7 @@ LL | std::mem::uninitialized::<&'static u32>();
68100
= note: references must be non-null
69101

70102
error: the type `std::boxed::Box<u32>` does not permit being left uninitialized
71-
--> $DIR/mem-uninitialized-future-compat.rs:34:9
103+
--> $DIR/mem-uninitialized-future-compat.rs:53:9
72104
|
73105
LL | std::mem::uninitialized::<Box<u32>>();
74106
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -80,7 +112,7 @@ LL | std::mem::uninitialized::<Box<u32>>();
80112
= note: `Box` must be non-null
81113

82114
error: the type `fn()` does not permit being left uninitialized
83-
--> $DIR/mem-uninitialized-future-compat.rs:37:9
115+
--> $DIR/mem-uninitialized-future-compat.rs:56:9
84116
|
85117
LL | std::mem::uninitialized::<fn()>();
86118
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -92,7 +124,7 @@ LL | std::mem::uninitialized::<fn()>();
92124
= note: function pointers must be non-null
93125

94126
error: the type `!` does not permit being left uninitialized
95-
--> $DIR/mem-uninitialized-future-compat.rs:40:9
127+
--> $DIR/mem-uninitialized-future-compat.rs:59:9
96128
|
97129
LL | std::mem::uninitialized::<!>();
98130
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -104,7 +136,7 @@ LL | std::mem::uninitialized::<!>();
104136
= note: the `!` type has no valid value
105137

106138
error: the type `*mut dyn std::io::Write` does not permit being left uninitialized
107-
--> $DIR/mem-uninitialized-future-compat.rs:43:9
139+
--> $DIR/mem-uninitialized-future-compat.rs:62:9
108140
|
109141
LL | std::mem::uninitialized::<*mut dyn std::io::Write>();
110142
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -116,7 +148,7 @@ LL | std::mem::uninitialized::<*mut dyn std::io::Write>();
116148
= note: the vtable of a wide raw pointer must be non-null
117149

118150
error: the type `bool` does not permit being left uninitialized
119-
--> $DIR/mem-uninitialized-future-compat.rs:46:9
151+
--> $DIR/mem-uninitialized-future-compat.rs:65:9
120152
|
121153
LL | std::mem::uninitialized::<bool>();
122154
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -128,7 +160,7 @@ LL | std::mem::uninitialized::<bool>();
128160
= note: booleans must be either `true` or `false`
129161

130162
error: the type `char` does not permit being left uninitialized
131-
--> $DIR/mem-uninitialized-future-compat.rs:49:9
163+
--> $DIR/mem-uninitialized-future-compat.rs:68:9
132164
|
133165
LL | std::mem::uninitialized::<char>();
134166
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -140,7 +172,7 @@ LL | std::mem::uninitialized::<char>();
140172
= note: characters must be a valid Unicode codepoint
141173

142174
error: the type `UninitStruct` does not permit being left uninitialized
143-
--> $DIR/mem-uninitialized-future-compat.rs:52:9
175+
--> $DIR/mem-uninitialized-future-compat.rs:71:9
144176
|
145177
LL | std::mem::uninitialized::<UninitStruct>();
146178
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -156,7 +188,7 @@ LL | b: char,
156188
| ^^^^^^^
157189

158190
error: the type `[UninitStruct; 16]` does not permit being left uninitialized
159-
--> $DIR/mem-uninitialized-future-compat.rs:55:9
191+
--> $DIR/mem-uninitialized-future-compat.rs:74:9
160192
|
161193
LL | std::mem::uninitialized::<[UninitStruct; 16]>();
162194
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -172,7 +204,7 @@ LL | b: char,
172204
| ^^^^^^^
173205

174206
error: the type `(u32, char)` does not permit being left uninitialized
175-
--> $DIR/mem-uninitialized-future-compat.rs:58:9
207+
--> $DIR/mem-uninitialized-future-compat.rs:77:9
176208
|
177209
LL | std::mem::uninitialized::<(u32, char)>();
178210
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -183,11 +215,107 @@ LL | std::mem::uninitialized::<(u32, char)>();
183215
= note: for more information, see FIXME: fill this in
184216
= note: characters must be a valid Unicode codepoint
185217

186-
error: aborting due to 14 previous errors
218+
error: the type `TwoVariant` does not permit being left uninitialized
219+
--> $DIR/mem-uninitialized-future-compat.rs:80:9
220+
|
221+
LL | std::mem::uninitialized::<TwoVariant>();
222+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
223+
| |
224+
| this code causes undefined behavior when executed
225+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
226+
|
227+
= note: for more information, see FIXME: fill this in
228+
note: enums have to be initialized to a variant
229+
--> $DIR/mem-uninitialized-future-compat.rs:16:1
230+
|
231+
LL | enum TwoVariant {
232+
| ^^^^^^^^^^^^^^^
233+
234+
error: the type `std::result::Result<!, !>` does not permit being left uninitialized
235+
--> $DIR/mem-uninitialized-future-compat.rs:83:9
236+
|
237+
LL | std::mem::uninitialized::<Result<!, !>>();
238+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
239+
| |
240+
| this code causes undefined behavior when executed
241+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
242+
|
243+
= note: for more information, see FIXME: fill this in
244+
note: enums have to be initialized to a variant
245+
--> $SRC_DIR/core/src/result.rs:LL:COL
246+
|
247+
LL | pub enum Result<T, E> {
248+
| ^^^^^^^^^^^^^^^^^^^^^
249+
250+
error: the type `std::result::Result<!, u32>` does not permit being left uninitialized
251+
--> $DIR/mem-uninitialized-future-compat.rs:86:9
252+
|
253+
LL | std::mem::uninitialized::<Result<!, u32>>();
254+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
255+
| |
256+
| this code causes undefined behavior when executed
257+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
258+
|
259+
= note: for more information, see FIXME: fill this in
260+
note: enums have to be initialized to a variant
261+
--> $SRC_DIR/core/src/result.rs:LL:COL
262+
|
263+
LL | pub enum Result<T, E> {
264+
| ^^^^^^^^^^^^^^^^^^^^^
265+
266+
error: the type `std::option::Option<!>` does not permit being left uninitialized
267+
--> $DIR/mem-uninitialized-future-compat.rs:89:9
268+
|
269+
LL | std::mem::uninitialized::<Option<!>>();
270+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
271+
| |
272+
| this code causes undefined behavior when executed
273+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
274+
|
275+
= note: for more information, see FIXME: fill this in
276+
note: enums have to be initialized to a variant
277+
--> $SRC_DIR/core/src/option.rs:LL:COL
278+
|
279+
LL | pub enum Option<T> {
280+
| ^^^^^^^^^^^^^^^^^^
281+
282+
error: the type `OneVariantWith<char>` does not permit being left uninitialized
283+
--> $DIR/mem-uninitialized-future-compat.rs:92:9
284+
|
285+
LL | std::mem::uninitialized::<OneVariantWith<char>>();
286+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
287+
| |
288+
| this code causes undefined behavior when executed
289+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
290+
|
291+
= note: for more information, see FIXME: fill this in
292+
note: characters must be a valid Unicode codepoint (in this enum field)
293+
--> $DIR/mem-uninitialized-future-compat.rs:22:11
294+
|
295+
LL | Hello(T),
296+
| ^
297+
298+
error: the type `OneVariantWith<!>` does not permit being left uninitialized
299+
--> $DIR/mem-uninitialized-future-compat.rs:95:9
300+
|
301+
LL | std::mem::uninitialized::<OneVariantWith<!>>();
302+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
303+
| |
304+
| this code causes undefined behavior when executed
305+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
306+
|
307+
= note: for more information, see FIXME: fill this in
308+
note: the `!` type has no valid value (in this enum field)
309+
--> $DIR/mem-uninitialized-future-compat.rs:22:11
310+
|
311+
LL | Hello(T),
312+
| ^
313+
314+
error: aborting due to 22 previous errors
187315

188316
Future incompatibility report: Future breakage diagnostic:
189317
error: the type `T` is generic, and might not permit being left uninitialized
190-
--> $DIR/mem-uninitialized-future-compat.rs:13:5
318+
--> $DIR/mem-uninitialized-future-compat.rs:26:5
191319
|
192320
LL | std::mem::uninitialized::<T>();
193321
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -205,7 +333,7 @@ LL | #![deny(mem_uninitialized)]
205333

206334
Future breakage diagnostic:
207335
error: the type `[T; N]` is generic, and might not permit being left uninitialized
208-
--> $DIR/mem-uninitialized-future-compat.rs:16:5
336+
--> $DIR/mem-uninitialized-future-compat.rs:29:5
209337
|
210338
LL | std::mem::uninitialized::<[T; N]>();
211339
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -223,7 +351,7 @@ LL | #![deny(mem_uninitialized)]
223351

224352
Future breakage diagnostic:
225353
error: the type `[char; N]` is generic, and might not permit being left uninitialized
226-
--> $DIR/mem-uninitialized-future-compat.rs:19:5
354+
--> $DIR/mem-uninitialized-future-compat.rs:32:5
227355
|
228356
LL | std::mem::uninitialized::<[char; N]>();
229357
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -241,7 +369,7 @@ LL | #![deny(mem_uninitialized)]
241369

242370
Future breakage diagnostic:
243371
error: the type `[UninitStruct; N]` is generic, and might not permit being left uninitialized
244-
--> $DIR/mem-uninitialized-future-compat.rs:22:5
372+
--> $DIR/mem-uninitialized-future-compat.rs:35:5
245373
|
246374
LL | std::mem::uninitialized::<[UninitStruct; N]>();
247375
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -261,9 +389,53 @@ note: characters must be a valid Unicode codepoint (in this struct field)
261389
LL | b: char,
262390
| ^^^^^^^
263391

392+
Future breakage diagnostic:
393+
error: the type `std::result::Result<T, !>` does not permit being left uninitialized
394+
--> $DIR/mem-uninitialized-future-compat.rs:38:5
395+
|
396+
LL | std::mem::uninitialized::<Result<T, !>>();
397+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
398+
| |
399+
| this code causes undefined behavior when executed
400+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
401+
|
402+
note: the lint level is defined here
403+
--> $DIR/mem-uninitialized-future-compat.rs:2:9
404+
|
405+
LL | #![deny(mem_uninitialized)]
406+
| ^^^^^^^^^^^^^^^^^
407+
= note: for more information, see FIXME: fill this in
408+
note: enums have to be initialized to a variant
409+
--> $SRC_DIR/core/src/result.rs:LL:COL
410+
|
411+
LL | pub enum Result<T, E> {
412+
| ^^^^^^^^^^^^^^^^^^^^^
413+
414+
Future breakage diagnostic:
415+
error: the type `OneVariantWith<T>` is generic, and might not permit being left uninitialized
416+
--> $DIR/mem-uninitialized-future-compat.rs:41:5
417+
|
418+
LL | std::mem::uninitialized::<OneVariantWith<T>>();
419+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
420+
| |
421+
| this code causes undefined behavior when executed
422+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
423+
|
424+
note: the lint level is defined here
425+
--> $DIR/mem-uninitialized-future-compat.rs:2:9
426+
|
427+
LL | #![deny(mem_uninitialized)]
428+
| ^^^^^^^^^^^^^^^^^
429+
= note: for more information, see FIXME: fill this in
430+
note: type might not be allowed to be left uninitialized (in this enum field)
431+
--> $DIR/mem-uninitialized-future-compat.rs:22:11
432+
|
433+
LL | Hello(T),
434+
| ^
435+
264436
Future breakage diagnostic:
265437
error: the type `&u32` does not permit being left uninitialized
266-
--> $DIR/mem-uninitialized-future-compat.rs:31:9
438+
--> $DIR/mem-uninitialized-future-compat.rs:50:9
267439
|
268440
LL | std::mem::uninitialized::<&'static u32>();
269441
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -281,7 +453,7 @@ LL | #![deny(mem_uninitialized)]
281453

282454
Future breakage diagnostic:
283455
error: the type `std::boxed::Box<u32>` does not permit being left uninitialized
284-
--> $DIR/mem-uninitialized-future-compat.rs:34:9
456+
--> $DIR/mem-uninitialized-future-compat.rs:53:9
285457
|
286458
LL | std::mem::uninitialized::<Box<u32>>();
287459
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -299,7 +471,7 @@ LL | #![deny(mem_uninitialized)]
299471

300472
Future breakage diagnostic:
301473
error: the type `fn()` does not permit being left uninitialized
302-
--> $DIR/mem-uninitialized-future-compat.rs:37:9
474+
--> $DIR/mem-uninitialized-future-compat.rs:56:9
303475
|
304476
LL | std::mem::uninitialized::<fn()>();
305477
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -317,7 +489,7 @@ LL | #![deny(mem_uninitialized)]
317489

318490
Future breakage diagnostic:
319491
error: the type `!` does not permit being left uninitialized
320-
--> $DIR/mem-uninitialized-future-compat.rs:40:9
492+
--> $DIR/mem-uninitialized-future-compat.rs:59:9
321493
|
322494
LL | std::mem::uninitialized::<!>();
323495
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -335,7 +507,7 @@ LL | #![deny(mem_uninitialized)]
335507

336508
Future breakage diagnostic:
337509
error: the type `*mut dyn std::io::Write` does not permit being left uninitialized
338-
--> $DIR/mem-uninitialized-future-compat.rs:43:9
510+
--> $DIR/mem-uninitialized-future-compat.rs:62:9
339511
|
340512
LL | std::mem::uninitialized::<*mut dyn std::io::Write>();
341513
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -353,7 +525,7 @@ LL | #![deny(mem_uninitialized)]
353525

354526
Future breakage diagnostic:
355527
error: the type `bool` does not permit being left uninitialized
356-
--> $DIR/mem-uninitialized-future-compat.rs:46:9
528+
--> $DIR/mem-uninitialized-future-compat.rs:65:9
357529
|
358530
LL | std::mem::uninitialized::<bool>();
359531
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -371,7 +543,7 @@ LL | #![deny(mem_uninitialized)]
371543

372544
Future breakage diagnostic:
373545
error: the type `char` does not permit being left uninitialized
374-
--> $DIR/mem-uninitialized-future-compat.rs:49:9
546+
--> $DIR/mem-uninitialized-future-compat.rs:68:9
375547
|
376548
LL | std::mem::uninitialized::<char>();
377549
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -389,7 +561,7 @@ LL | #![deny(mem_uninitialized)]
389561

390562
Future breakage diagnostic:
391563
error: the type `UninitStruct` does not permit being left uninitialized
392-
--> $DIR/mem-uninitialized-future-compat.rs:52:9
564+
--> $DIR/mem-uninitialized-future-compat.rs:71:9
393565
|
394566
LL | std::mem::uninitialized::<UninitStruct>();
395567
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -411,7 +583,7 @@ LL | b: char,
411583

412584
Future breakage diagnostic:
413585
error: the type `[UninitStruct; 16]` does not permit being left uninitialized
414-
--> $DIR/mem-uninitialized-future-compat.rs:55:9
586+
--> $DIR/mem-uninitialized-future-compat.rs:74:9
415587
|
416588
LL | std::mem::uninitialized::<[UninitStruct; 16]>();
417589
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -433,7 +605,7 @@ LL | b: char,
433605

434606
Future breakage diagnostic:
435607
error: the type `(u32, char)` does not permit being left uninitialized
436-
--> $DIR/mem-uninitialized-future-compat.rs:58:9
608+
--> $DIR/mem-uninitialized-future-compat.rs:77:9
437609
|
438610
LL | std::mem::uninitialized::<(u32, char)>();
439611
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -449,3 +621,135 @@ LL | #![deny(mem_uninitialized)]
449621
= note: for more information, see FIXME: fill this in
450622
= note: characters must be a valid Unicode codepoint
451623

624+
Future breakage diagnostic:
625+
error: the type `TwoVariant` does not permit being left uninitialized
626+
--> $DIR/mem-uninitialized-future-compat.rs:80:9
627+
|
628+
LL | std::mem::uninitialized::<TwoVariant>();
629+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
630+
| |
631+
| this code causes undefined behavior when executed
632+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
633+
|
634+
note: the lint level is defined here
635+
--> $DIR/mem-uninitialized-future-compat.rs:2:9
636+
|
637+
LL | #![deny(mem_uninitialized)]
638+
| ^^^^^^^^^^^^^^^^^
639+
= note: for more information, see FIXME: fill this in
640+
note: enums have to be initialized to a variant
641+
--> $DIR/mem-uninitialized-future-compat.rs:16:1
642+
|
643+
LL | enum TwoVariant {
644+
| ^^^^^^^^^^^^^^^
645+
646+
Future breakage diagnostic:
647+
error: the type `std::result::Result<!, !>` does not permit being left uninitialized
648+
--> $DIR/mem-uninitialized-future-compat.rs:83:9
649+
|
650+
LL | std::mem::uninitialized::<Result<!, !>>();
651+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
652+
| |
653+
| this code causes undefined behavior when executed
654+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
655+
|
656+
note: the lint level is defined here
657+
--> $DIR/mem-uninitialized-future-compat.rs:2:9
658+
|
659+
LL | #![deny(mem_uninitialized)]
660+
| ^^^^^^^^^^^^^^^^^
661+
= note: for more information, see FIXME: fill this in
662+
note: enums have to be initialized to a variant
663+
--> $SRC_DIR/core/src/result.rs:LL:COL
664+
|
665+
LL | pub enum Result<T, E> {
666+
| ^^^^^^^^^^^^^^^^^^^^^
667+
668+
Future breakage diagnostic:
669+
error: the type `std::result::Result<!, u32>` does not permit being left uninitialized
670+
--> $DIR/mem-uninitialized-future-compat.rs:86:9
671+
|
672+
LL | std::mem::uninitialized::<Result<!, u32>>();
673+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
674+
| |
675+
| this code causes undefined behavior when executed
676+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
677+
|
678+
note: the lint level is defined here
679+
--> $DIR/mem-uninitialized-future-compat.rs:2:9
680+
|
681+
LL | #![deny(mem_uninitialized)]
682+
| ^^^^^^^^^^^^^^^^^
683+
= note: for more information, see FIXME: fill this in
684+
note: enums have to be initialized to a variant
685+
--> $SRC_DIR/core/src/result.rs:LL:COL
686+
|
687+
LL | pub enum Result<T, E> {
688+
| ^^^^^^^^^^^^^^^^^^^^^
689+
690+
Future breakage diagnostic:
691+
error: the type `std::option::Option<!>` does not permit being left uninitialized
692+
--> $DIR/mem-uninitialized-future-compat.rs:89:9
693+
|
694+
LL | std::mem::uninitialized::<Option<!>>();
695+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
696+
| |
697+
| this code causes undefined behavior when executed
698+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
699+
|
700+
note: the lint level is defined here
701+
--> $DIR/mem-uninitialized-future-compat.rs:2:9
702+
|
703+
LL | #![deny(mem_uninitialized)]
704+
| ^^^^^^^^^^^^^^^^^
705+
= note: for more information, see FIXME: fill this in
706+
note: enums have to be initialized to a variant
707+
--> $SRC_DIR/core/src/option.rs:LL:COL
708+
|
709+
LL | pub enum Option<T> {
710+
| ^^^^^^^^^^^^^^^^^^
711+
712+
Future breakage diagnostic:
713+
error: the type `OneVariantWith<char>` does not permit being left uninitialized
714+
--> $DIR/mem-uninitialized-future-compat.rs:92:9
715+
|
716+
LL | std::mem::uninitialized::<OneVariantWith<char>>();
717+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
718+
| |
719+
| this code causes undefined behavior when executed
720+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
721+
|
722+
note: the lint level is defined here
723+
--> $DIR/mem-uninitialized-future-compat.rs:2:9
724+
|
725+
LL | #![deny(mem_uninitialized)]
726+
| ^^^^^^^^^^^^^^^^^
727+
= note: for more information, see FIXME: fill this in
728+
note: characters must be a valid Unicode codepoint (in this enum field)
729+
--> $DIR/mem-uninitialized-future-compat.rs:22:11
730+
|
731+
LL | Hello(T),
732+
| ^
733+
734+
Future breakage diagnostic:
735+
error: the type `OneVariantWith<!>` does not permit being left uninitialized
736+
--> $DIR/mem-uninitialized-future-compat.rs:95:9
737+
|
738+
LL | std::mem::uninitialized::<OneVariantWith<!>>();
739+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
740+
| |
741+
| this code causes undefined behavior when executed
742+
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
743+
|
744+
note: the lint level is defined here
745+
--> $DIR/mem-uninitialized-future-compat.rs:2:9
746+
|
747+
LL | #![deny(mem_uninitialized)]
748+
| ^^^^^^^^^^^^^^^^^
749+
= note: for more information, see FIXME: fill this in
750+
note: the `!` type has no valid value (in this enum field)
751+
--> $DIR/mem-uninitialized-future-compat.rs:22:11
752+
|
753+
LL | Hello(T),
754+
| ^
755+

0 commit comments

Comments
 (0)
Please sign in to comment.