about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/memleak_rc.rs
blob: 2d12c1223cf283a0164fbe1bdf468b540c09b6e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//@error-in-other-file: memory leaked
//@normalize-stderr-test: ".*│.*" -> "$$stripped$$"
//@normalize-stderr-test: "Rust heap, size: [0-9]+, align: [0-9]+" -> "Rust heap, SIZE, ALIGN"

use std::cell::RefCell;
use std::rc::Rc;

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