0
0
mirror of https://github.com/rust-lang/rust.git synced 2024-11-28 21:12:18 +01:00
rust/tests/ui/coroutine/ref-escapes-but-not-over-yield.rs
2023-10-20 21:14:02 +00:00

17 lines
423 B
Rust

#![feature(coroutines)]
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 = move || {
yield();
let b = 5;
a = &b;
//~^ ERROR borrowed data escapes outside of coroutine
};
}
fn main() { }