diff options
Diffstat (limited to 'tests/ui/generator/static-coroutine.rs')
| -rw-r--r-- | tests/ui/generator/static-coroutine.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/generator/static-coroutine.rs b/tests/ui/generator/static-coroutine.rs new file mode 100644 index 00000000000..f9fd65b9793 --- /dev/null +++ b/tests/ui/generator/static-coroutine.rs @@ -0,0 +1,20 @@ +// run-pass + +#![feature(coroutines, coroutine_trait)] + +use std::pin::Pin; +use std::ops::{Coroutine, CoroutineState}; + +fn main() { + let mut coroutine = static || { + let a = true; + let b = &a; + yield; + assert_eq!(b as *const _, &a as *const _); + }; + // SAFETY: We shadow the original coroutine variable so have no safe API to + // move it after this point. + let mut coroutine = unsafe { Pin::new_unchecked(&mut coroutine) }; + assert_eq!(coroutine.as_mut().resume(()), CoroutineState::Yielded(())); + assert_eq!(coroutine.as_mut().resume(()), CoroutineState::Complete(())); +} |
