mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-10-02 14:44:32 +00:00
16 lines
426 B
Rust
16 lines
426 B
Rust
use embassy_sync::lazy_lock::LazyLock;
|
|
|
|
fn main() {
|
|
let x = 128u8;
|
|
let x_ptr: *const u8 = core::ptr::addr_of!(x);
|
|
|
|
let closure_capturing_non_sync_variable = || {
|
|
unsafe {
|
|
core::ptr::read(x_ptr)
|
|
}
|
|
};
|
|
|
|
// This should fail to compile because the closure captures a non-Sync variable: x_ptr.
|
|
let _lazy_u8: LazyLock<u8, _> = LazyLock::new(closure_capturing_non_sync_variable);
|
|
}
|