rust/tests/ui/coroutine/ref-escapes-but-not-over-yield.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
462 B
Rust
Raw Normal View History

#![feature(coroutines, stmt_expr_attributes)]
fn foo(x: &i32) {
2023-10-19 21:46:28 +00:00
// 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;
2017-11-20 12:13:27 +00:00
a = &b;
2023-10-19 21:46:28 +00:00
//~^ ERROR borrowed data escapes outside of coroutine
2017-12-14 01:27:23 +00:00
};
}
fn main() {}