You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnfoo(){use std::ops::{GeneratorState,Generator};
|| {let a = {letmut f = || {iffalse{yield}format!("a")};let a = loop{match f.resume(){GeneratorState::Complete(e) => break e,GeneratorState::Yielded(()) => {}}yield};
a.len()};iffalse{yield}return a
};}
generates the error:
error[E0597]: `a` does not live long enough
--> tests/smoke.rs:112:9
|
111 | a.len()
| - borrow occurs here
112 | };
| ^ `a` dropped here while still borrowed
...
115 | };
| - borrowed value needs to live until here
error: aborting due to previous error
fnfoo(){use std::ops::{GeneratorState,Generator};
|| {let a = {letmut f = || {iffalse{yield}format!("a")};let a = loop{match f.resume(){GeneratorState::Complete(e) => break e,GeneratorState::Yielded(()) => {}}yield// [X] this yield};
a.len()// [X] is caught up by this expression};iffalse{yield}return a
};}
This code:
generates the error:
but naively at least I'd expect it to work!
cc @Zoxc
The text was updated successfully, but these errors were encountered: