Skip to content

Commit eb14dd8

Browse files
committed
Test NLL fix of bad lifetime inference for reference captured in closure.
1 parent 1f34da9 commit eb14dd8

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)