rust/tests/compile-fail/memleak_rc.rs
2017-02-24 10:41:15 +01:00

13 lines
266 B
Rust

//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);
}