From 5fd561dea24d137734195d8d2dc82fe179553b2d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 14 Nov 2022 13:38:53 +0100 Subject: [PATCH] avoid memory leak in mpsc test --- library/std/src/sync/mpsc/tests.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/std/src/sync/mpsc/tests.rs b/library/std/src/sync/mpsc/tests.rs index 82c52eb4fef45..1e52a4a705c98 100644 --- a/library/std/src/sync/mpsc/tests.rs +++ b/library/std/src/sync/mpsc/tests.rs @@ -713,10 +713,11 @@ fn issue_39364() { let t = thread::spawn(move || { thread::sleep(Duration::from_millis(300)); let _ = tx.clone(); - crate::mem::forget(tx); + // Don't drop; hand back to caller. + tx }); let _ = rx.recv_timeout(Duration::from_millis(500)); - t.join().unwrap(); + let _tx = t.join().unwrap(); // delay dropping until end of test let _ = rx.recv_timeout(Duration::from_millis(500)); }