diff options
| author | Melvin Wang <[email protected]> | 2025-06-18 16:16:06 -0700 |
|---|---|---|
| committer | Melvin Wang <[email protected]> | 2025-06-18 16:16:12 -0700 |
| commit | 3a432920978dc48f0b4c0a8da7c118415a0708fd (patch) | |
| tree | 9db0e9fca33b4be0f18941a7cc21e6c89ebdc1b9 /embassy-sync/tests/ui/sync_impl/lazy_lock_function.rs | |
| parent | 051c63fea2fdb9cc9773c3bd311e6c423f3d1cd2 (diff) | |
commit expected errors
Diffstat (limited to 'embassy-sync/tests/ui/sync_impl/lazy_lock_function.rs')
| -rw-r--r-- | embassy-sync/tests/ui/sync_impl/lazy_lock_function.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/embassy-sync/tests/ui/sync_impl/lazy_lock_function.rs b/embassy-sync/tests/ui/sync_impl/lazy_lock_function.rs index c6e6f7e64..35f5587c0 100644 --- a/embassy-sync/tests/ui/sync_impl/lazy_lock_function.rs +++ b/embassy-sync/tests/ui/sync_impl/lazy_lock_function.rs | |||
| @@ -3,13 +3,9 @@ use embassy_sync::lazy_lock::LazyLock; | |||
| 3 | fn main() { | 3 | fn main() { |
| 4 | let x = 128u8; | 4 | let x = 128u8; |
| 5 | let x_ptr: *const u8 = core::ptr::addr_of!(x); | 5 | let x_ptr: *const u8 = core::ptr::addr_of!(x); |
| 6 | let closure_capturing_non_sync_variable = || unsafe { core::ptr::read(x_ptr) }; | ||
| 6 | 7 | ||
| 7 | let closure_capturing_non_sync_variable = || { | 8 | check_sync(LazyLock::new(closure_capturing_non_sync_variable)); |
| 8 | unsafe { | ||
| 9 | core::ptr::read(x_ptr) | ||
| 10 | } | ||
| 11 | }; | ||
| 12 | |||
| 13 | // This should fail to compile because the closure captures a non-Sync variable: x_ptr. | ||
| 14 | let _lazy_u8: LazyLock<u8, _> = LazyLock::new(closure_capturing_non_sync_variable); | ||
| 15 | } | 9 | } |
| 10 | |||
| 11 | fn check_sync<T: Sync>(_lazy_lock: T) {} | ||
