]> git.lizzy.rs Git - rust.git/blob - tests/ui/generator/generator-resume-after-panic.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / generator / generator-resume-after-panic.rs
1 // run-fail
2 // needs-unwind
3 // error-pattern:generator resumed after panicking
4 // ignore-emscripten no processes
5
6 // Test that we get the correct message for resuming a panicked generator.
7
8 #![feature(generators, generator_trait)]
9
10 use std::{
11     ops::Generator,
12     pin::Pin,
13     panic,
14 };
15
16 fn main() {
17     let mut g = || {
18         panic!();
19         yield;
20     };
21     panic::catch_unwind(panic::AssertUnwindSafe(|| {
22         let x = Pin::new(&mut g).resume(());
23     }));
24     Pin::new(&mut g).resume(());
25 }