fix memory leak in test
This commit is contained in:
parent
4652a13f44
commit
01f36c51c2
@ -250,14 +250,19 @@ fn uninit_write_slice_cloned_mid_panic() {
|
||||
|
||||
#[test]
|
||||
fn uninit_write_slice_cloned_no_drop() {
|
||||
let rc = Rc::new(());
|
||||
#[derive(Clone)]
|
||||
struct Bomb;
|
||||
|
||||
impl Drop for Bomb {
|
||||
fn drop(&mut self) {
|
||||
panic!("dropped a bomb! kaboom")
|
||||
}
|
||||
}
|
||||
|
||||
let mut dst = [MaybeUninit::uninit()];
|
||||
let src = [rc.clone()];
|
||||
let src = [Bomb];
|
||||
|
||||
MaybeUninit::write_slice_cloned(&mut dst, &src);
|
||||
|
||||
drop(src);
|
||||
|
||||
assert_eq!(Rc::strong_count(&rc), 2);
|
||||
forget(src);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user