mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 13:40:15 +03:00
add test with an Rc cycle to create a memleak
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user