Skip to content

Commit 01f36c5

Browse files
committed
fix memory leak in test
1 parent 4652a13 commit 01f36c5

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Diff for: library/core/tests/mem.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,19 @@ fn uninit_write_slice_cloned_mid_panic() {
250250

251251
#[test]
252252
fn uninit_write_slice_cloned_no_drop() {
253-
let rc = Rc::new(());
253+
#[derive(Clone)]
254+
struct Bomb;
255+
256+
impl Drop for Bomb {
257+
fn drop(&mut self) {
258+
panic!("dropped a bomb! kaboom")
259+
}
260+
}
254261

255262
let mut dst = [MaybeUninit::uninit()];
256-
let src = [rc.clone()];
263+
let src = [Bomb];
257264

258265
MaybeUninit::write_slice_cloned(&mut dst, &src);
259266

260-
drop(src);
261-
262-
assert_eq!(Rc::strong_count(&rc), 2);
267+
forget(src);
263268
}

0 commit comments

Comments
 (0)