1 #![feature(generators, generator_trait)]
3 use std::cell::RefCell;
4 use std::ops::Generator;
9 cell = Box::new(RefCell::new(0));
10 let ref_ = Box::leak(Box::new(Some(cell.borrow_mut())));
11 //~^ ERROR `*cell` does not live long enough [E0597]
12 // the upvar is the non-dropck `&mut Option<Ref<'a, i32>>`.
14 // but the generator can use it to drop a `Ref<'a, i32>`.
15 let _d = ref_.take(); //~ ERROR `ref_` does not live long enough
18 Pin::new(&mut gen).resume(());
19 // drops the RefCell and then the Ref, leading to use-after-free