File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
src/tools/miri/tests/pass Expand file tree Collapse file tree 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() {
220220 } ) ;
221221}
222222
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+
223253fn main ( ) {
224254 basic ( ) ;
225255 smoke_resume_arg ( ) ;
256+ uninit_fields ( ) ;
226257}
You can’t perform that action at this time.
0 commit comments