2024-04-11 08:15:34 -05:00
|
|
|
#![feature(coroutines, stmt_expr_attributes)]
|
2017-07-14 18:11:21 -05:00
|
|
|
|
2017-07-15 05:52:49 -05:00
|
|
|
fn foo(x: &i32) {
|
2023-10-19 16:46:28 -05:00
|
|
|
// In this case, a reference to `b` escapes the coroutine, but not
|
2017-07-15 05:52:49 -05:00
|
|
|
// 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;
|
2024-04-11 08:15:34 -05:00
|
|
|
let mut b = #[coroutine]
|
|
|
|
move || {
|
|
|
|
yield ();
|
2017-07-15 05:52:49 -05:00
|
|
|
let b = 5;
|
2017-11-20 06:13:27 -06:00
|
|
|
a = &b;
|
2023-10-19 16:46:28 -05:00
|
|
|
//~^ ERROR borrowed data escapes outside of coroutine
|
2017-12-13 19:27:23 -06:00
|
|
|
};
|
2017-07-14 18:11:21 -05:00
|
|
|
}
|
|
|
|
|
2024-04-11 08:15:34 -05:00
|
|
|
fn main() {}
|