add test with an Rc cycle to create a memleak
This commit is contained in:
parent
5829483f4d
commit
38d16ccacc
1 changed files with 12 additions and 0 deletions
12
tests/compile-fail/memleak_rc.rs
Normal file
12
tests/compile-fail/memleak_rc.rs
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue