3 use std::cell::RefCell;
5 struct S<'a>(i32, &'a RefCell<Vec<i32>>);
7 impl<'a> Drop for S<'a> {
9 self.1.borrow_mut().push(self.0);
13 fn test(drops: &RefCell<Vec<i32>>) {
15 let pfoo: *mut _ = &mut foo;
22 // Both S(0) and S(1) should be dropped, but aren't.
23 unsafe { *pfoo = Some((S(0, drops), S(1, drops))); }
32 let drops = RefCell::new(Vec::new());
35 // Ideally, we want this...
36 //assert_eq!(*drops.borrow(), &[0, 1]);
38 // But the delayed access through the raw pointer confuses drop elaboration,
39 // causing S(1) to be leaked.
40 assert_eq!(*drops.borrow(), &[0]);