File tree 1 file changed +31
-0
lines changed
src/tools/miri/tests/pass
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -220,7 +220,38 @@ fn smoke_resume_arg() {
220
220
} ) ;
221
221
}
222
222
223
+ fn uninit_fields ( ) {
224
+ // Test that uninhabited saved local doesn't make the entire variant uninhabited.
225
+ // (https://github.com/rust-lang/rust/issues/115145, https://github.com/rust-lang/rust/pull/118871)
226
+ fn conjure < T > ( ) -> T {
227
+ loop { }
228
+ }
229
+
230
+ fn run < T > ( x : bool , y : bool ) {
231
+ let mut c = || {
232
+ if x {
233
+ let _a: T ;
234
+ if y {
235
+ _a = conjure :: < T > ( ) ;
236
+ }
237
+ yield ( ) ;
238
+ } else {
239
+ let _a: T ;
240
+ if y {
241
+ _a = conjure :: < T > ( ) ;
242
+ }
243
+ yield ( ) ;
244
+ }
245
+ } ;
246
+ assert ! ( matches!( Pin :: new( & mut c) . resume( ( ) ) , CoroutineState :: Yielded ( ( ) ) ) ) ;
247
+ assert ! ( matches!( Pin :: new( & mut c) . resume( ( ) ) , CoroutineState :: Complete ( ( ) ) ) ) ;
248
+ }
249
+
250
+ run :: < !> ( false , false ) ;
251
+ }
252
+
223
253
fn main ( ) {
224
254
basic ( ) ;
225
255
smoke_resume_arg ( ) ;
256
+ uninit_fields ( ) ;
226
257
}
You can’t perform that action at this time.
0 commit comments