1
Fork 0

add test with an Rc cycle to create a memleak

This commit is contained in:
Oliver Schneider 2017-02-15 16:38:27 +01:00
parent 5829483f4d
commit 38d16ccacc
No known key found for this signature in database
GPG key ID: A69F8D225B3AD7D9

View file

@ -0,0 +1,12 @@
//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);
}