mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
aef0f4024a
And suggest adding the `#[coroutine]` to the closure
18 lines
462 B
Rust
18 lines
462 B
Rust
#![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() {}
|