diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-06-17 07:16:56 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-17 07:16:56 +0900 |
| commit | 1f3023ca8ad6ddf69d4689278819dd432a7bcc02 (patch) | |
| tree | 9c6a976747ac6d722c58a36af42ee7876ae408fd /library/std/src | |
| parent | cf68fd7e8d3cf3d075208d9a09aa509eeb87b4ee (diff) | |
| parent | eb14dd863a0d8af603c6783b10efff8454944c15 (diff) | |
| download | rust-1f3023ca8ad6ddf69d4689278819dd432a7bcc02.tar.gz rust-1f3023ca8ad6ddf69d4689278819dd432a7bcc02.zip | |
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.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/thread/tests.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs index 5b8309cf5d2..ec68b529188 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); +} |
