rust/src/test/ui/generator/ref-escapes-but-not-over-yield.rs
2019-01-27 22:58:53 +01:00

17 lines
410 B
Rust

#![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;
a = &b;
//~^ ERROR `b` does not live long enough
};
}
fn main() { }