Ensure upvars are dropped when generators have never been resumed

This commit is contained in:
John Kåre Alsaker 2017-07-10 20:04:15 +02:00
parent facabcb85e
commit 075fd364d0
3 changed files with 118 additions and 48 deletions

View file

@ -13,5 +13,5 @@
fn main() {
let gen = |start| { //~ ERROR generators cannot have explicit arguments
yield;
};
};
}

View file

@ -58,7 +58,7 @@ fn t2() {
fn t3() {
let b = B;
let mut foo = || {
let foo = || {
let _: () = gen arg; // TODO: this line should not be necessary
yield;
drop(b);
@ -67,7 +67,5 @@ fn t3() {
let n = A.load(Ordering::SeqCst);
assert_eq!(A.load(Ordering::SeqCst), n);
drop(foo);
// TODO: we should assert n+1 here, not n
// assert_eq!(A.load(Ordering::SeqCst), n + 1);
assert_eq!(A.load(Ordering::SeqCst), n);
assert_eq!(A.load(Ordering::SeqCst), n + 1);
}