2018-10-04 20:49:38 +02:00
|
|
|
#![feature(generators)]
|
2017-07-14 19:11:21 -04:00
|
|
|
|
2017-07-15 06:52:49 -04:00
|
|
|
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 13:13:27 +01:00
|
|
|
a = &b;
|
2019-04-22 08:40:08 +01:00
|
|
|
//~^ ERROR borrowed data escapes outside of generator
|
2017-12-13 17:27:23 -08:00
|
|
|
};
|
2017-07-14 19:11:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|