From eb14dd863a0d8af603c6783b10efff8454944c15 Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Wed, 15 Jun 2022 03:12:07 +0200 Subject: [PATCH] Test NLL fix of bad lifetime inference for reference captured in closure. --- library/std/src/thread/tests.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs index 5b8309cf5d273..ec68b52918802 100644 --- a/library/std/src/thread/tests.rs +++ b/library/std/src/thread/tests.rs @@ -316,3 +316,16 @@ fn test_scoped_threads_drop_result_before_join() { }); assert!(actually_finished.load(Ordering::Relaxed)); } + +#[test] +fn test_scoped_threads_nll() { + // this is mostly a *compilation test* for this exact function: + fn foo(x: &u8) { + thread::scope(|s| { + s.spawn(|| drop(x)); + }); + } + // let's also run it for good measure + let x = 42_u8; + foo(&x); +}