about summary refs log tree commit diff
path: root/tests/ui/coroutine/ref-escapes-but-not-over-yield.rs
blob: 0f9c56786da065558aff752c0b7cd706d13414f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#![feature(coroutines, stmt_expr_attributes)]

fn foo(x: &i32) {
    // In this case, a reference to `b` escapes the coroutine, but not
    // because of a yield. We see that there is no yield in the scope of
    // `b` and give the more generic error message.
    let mut a = &3;
    let mut b = #[coroutine]
    move || {
        yield ();
        let b = 5;
        a = &b;
        //~^ ERROR borrowed data escapes outside of coroutine
    };
}

fn main() {}