Skip to content

Commit a75b292

Browse files
committed
Dereference pointer before async block
1 parent eeec389 commit a75b292

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

embedded-hal-async/src/spi.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ where
6161
/// ```
6262
macro_rules! spi_transaction_helper {
6363
($device:expr, move |$bus:ident| async move $closure_body:expr) => {
64-
$crate::spi::SpiDevice::transaction($device, move |$bus| async move {
64+
$crate::spi::SpiDevice::transaction($device, move |$bus| {
6565
// Safety: Implementers of the `SpiDevice` trait guarantee that the pointer is
6666
// valid and dereferencable for the entire duration of the closure.
6767
let $bus = unsafe { &mut *$bus };
68-
let result = $closure_body;
69-
let $bus = $bus; // Ensure that the bus reference was not moved out of the closure
70-
let _ = $bus; // Silence the "unused variable" warning from prevous line
71-
result
68+
async move {
69+
let result = $closure_body;
70+
let $bus = $bus; // Ensure that the bus reference was not moved out of the closure
71+
let _ = $bus; // Silence the "unused variable" warning from prevous line
72+
result
73+
}
7274
})
7375
};
7476
}

0 commit comments

Comments
 (0)