summaryrefslogtreecommitdiffstats
path: root/tests/ui/async-await/issues/issue-65419/issue-65419-coroutine-resume-after-completion.rs
blob: e16b86f957920deb4fed0d758aafa93038f6884c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// issue 65419 - Attempting to run an `async fn` after completion mentions coroutines when it should
// be talking about `async fn`s instead. Regression test added to make sure coroutines still
// panic when resumed after completion.

// run-fail
// error-pattern:coroutine resumed after completion
// edition:2018
// ignore-wasm no panic or subprocess support
// ignore-emscripten no panic or subprocess support

#![feature(coroutines, coroutine_trait)]

use std::{
    ops::Coroutine,
    pin::Pin,
};

fn main() {
    let mut g = || {
        yield;
    };
    Pin::new(&mut g).resume(()); // Yields once.
    Pin::new(&mut g).resume(()); // Completes here.
    Pin::new(&mut g).resume(()); // Panics here.
}