about summary refs log tree commit diff
path: root/tests/mir-opt/coroutine_tiny.rs
blob: 81e9940541ba082020e1e497bb75d7ec3eca7c5c (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
26
27
28
// skip-filecheck
//! Tests that coroutines that cannot return or unwind don't have unnecessary
//! panic branches.

//@ compile-flags: -C panic=abort
//@ no-prefer-dynamic

#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]

struct HasDrop;

impl Drop for HasDrop {
    fn drop(&mut self) {}
}

fn callee() {}

// EMIT_MIR coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir
fn main() {
    let _gen = #[coroutine]
    |_x: u8| {
        let _d = HasDrop;
        loop {
            yield;
            callee();
        }
    };
}