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

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

17 lines
423 B
Rust
Raw Normal View History

2018-10-04 13:49:38 -05:00
#![feature(generators)]
fn foo(x: &i32) {
// In this case, a reference to `b` escapes the generator, 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;
2017-11-20 06:13:27 -06:00
a = &b;
//~^ ERROR borrowed data escapes outside of generator
2017-12-13 19:27:23 -06:00
};
}
fn main() { }