rust/tests/compile-fail/memleak_rc.rs
2020-03-27 19:39:35 +01:00

15 lines
319 B
Rust

// ignore-windows: We do not check leaks on Windows
//error-pattern: the evaluated program leaked memory
use std::rc::Rc;
use std::cell::RefCell;
struct Dummy(Rc<RefCell<Option<Dummy>>>);
fn main() {
let x = Dummy(Rc::new(RefCell::new(None)));
let y = Dummy(x.0.clone());
*x.0.borrow_mut() = Some(y);
}