Skip to content

Commit 1f3023c

Browse files
authored
Rollup merge of #98118 - steffahn:scoped-threads-nll-test, r=m-ou-se
Test NLL fix of bad lifetime inference for reference captured in closure. This came up as a use-case for `thread::scope` API that only compiles successfully since `feature(nll)` got stabilized recently. Closes #93203 which had been re-opened for tracking this very test case to be added.
2 parents cf68fd7 + eb14dd8 commit 1f3023c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

library/std/src/thread/tests.rs

+13
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,16 @@ fn test_scoped_threads_drop_result_before_join() {
316316
});
317317
assert!(actually_finished.load(Ordering::Relaxed));
318318
}
319+
320+
#[test]
321+
fn test_scoped_threads_nll() {
322+
// this is mostly a *compilation test* for this exact function:
323+
fn foo(x: &u8) {
324+
thread::scope(|s| {
325+
s.spawn(|| drop(x));
326+
});
327+
}
328+
// let's also run it for good measure
329+
let x = 42_u8;
330+
foo(&x);
331+
}

0 commit comments

Comments
 (0)