diff options
| author | bors <bors@rust-lang.org> | 2023-12-14 06:58:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-14 06:58:28 +0000 |
| commit | 5747646aab51c430690afa993aa5268cfd00cd8c (patch) | |
| tree | 9f28a51054520b3085969a79d939fd0443ba4d23 | |
| parent | 4a4a8966bd140a0e28d6a26c4e504514f2e7067a (diff) | |
| parent | 823e2e784220d96b5ca27f0a6b2751994958c965 (diff) | |
Auto merge of #3225 - RalfJung:coroutine, r=RalfJung
add test for uninhabited saved locals in a coroutine adds the test from https://github.com/rust-lang/rust/pull/118871 in Miri as well
| -rw-r--r-- | src/tools/miri/tests/pass/coroutine.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tools/miri/tests/pass/coroutine.rs b/src/tools/miri/tests/pass/coroutine.rs index 49bfa92a052..7e1f64df04d 100644 --- a/src/tools/miri/tests/pass/coroutine.rs +++ b/src/tools/miri/tests/pass/coroutine.rs @@ -220,7 +220,38 @@ fn smoke_resume_arg() { }); } +fn uninit_fields() { + // Test that uninhabited saved local doesn't make the entire variant uninhabited. + // (https://github.com/rust-lang/rust/issues/115145, https://github.com/rust-lang/rust/pull/118871) + fn conjure<T>() -> T { + loop {} + } + + fn run<T>(x: bool, y: bool) { + let mut c = || { + if x { + let _a: T; + if y { + _a = conjure::<T>(); + } + yield (); + } else { + let _a: T; + if y { + _a = conjure::<T>(); + } + yield (); + } + }; + assert!(matches!(Pin::new(&mut c).resume(()), CoroutineState::Yielded(()))); + assert!(matches!(Pin::new(&mut c).resume(()), CoroutineState::Complete(()))); + } + + run::<!>(false, false); +} + fn main() { basic(); smoke_resume_arg(); + uninit_fields(); } |
