@@ -9,6 +9,19 @@ struct UninitStruct {
9
9
b : char ,
10
10
}
11
11
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
+
12
25
unsafe fn unknown_type < T , const N : usize > ( ) {
13
26
std:: mem:: uninitialized :: < T > ( ) ;
14
27
//~^ 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>() {
22
35
std:: mem:: uninitialized :: < [ UninitStruct ; N ] > ( ) ;
23
36
//~^ ERROR the type `[UninitStruct; N]` is generic, and might not permit being left uninitialized
24
37
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
+
25
44
std:: mem:: uninitialized :: < [ T ; 0 ] > ( ) ;
26
45
std:: mem:: uninitialized :: < [ char ; 0 ] > ( ) ;
27
46
}
@@ -58,10 +77,30 @@ fn main() {
58
77
std:: mem:: uninitialized :: < ( u32 , char ) > ( ) ;
59
78
//~^ ERROR the type `(u32, char)` does not permit being left uninitialized
60
79
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
+
61
98
std:: mem:: uninitialized :: < MaybeUninit < Box < u32 > > > ( ) ;
62
99
std:: mem:: uninitialized :: < usize > ( ) ;
63
100
std:: mem:: uninitialized :: < f32 > ( ) ;
64
101
std:: mem:: uninitialized :: < * const u8 > ( ) ;
65
102
std:: mem:: uninitialized :: < [ u8 ; 64 ] > ( ) ;
103
+ std:: mem:: uninitialized :: < OneVariant > ( ) ;
104
+ std:: mem:: uninitialized :: < OneVariantWith < u32 > > ( ) ;
66
105
}
67
106
}
0 commit comments