From 55595ca1b74e07eb2365d5aec3861600e2266470 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Mon, 5 Dec 2022 08:10:22 -0800 Subject: fix(ops): disallow auto-borrowing OpState across potential await point (#16952) Fixes https://github.com/denoland/deno/issues/16934 Example compiler error: ``` error: mutable opstate is not supported in async ops --> core/ops_builtin.rs:122:1 | 122 | #[op] | ^^^^^ | = note: this error originates in the attribute macro `op` (in Nightly builds, run with -Z macro-backtrace for more info) ``` --- ext/flash/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ext/flash/lib.rs') diff --git a/ext/flash/lib.rs b/ext/flash/lib.rs index d08cdbcdc..04ed54e1a 100644 --- a/ext/flash/lib.rs +++ b/ext/flash/lib.rs @@ -1290,10 +1290,11 @@ where #[op] fn op_flash_wait_for_listening( - state: &mut OpState, + state: Rc>, server_id: u32, ) -> Result> + 'static, AnyError> { let mut listening_rx = { + let mut state = state.borrow_mut(); let flash_ctx = state.borrow_mut::(); let server_ctx = flash_ctx .servers @@ -1312,10 +1313,11 @@ fn op_flash_wait_for_listening( #[op] fn op_flash_drive_server( - state: &mut OpState, + state: Rc>, server_id: u32, ) -> Result> + 'static, AnyError> { let join_handle = { + let mut state = state.borrow_mut(); let flash_ctx = state.borrow_mut::(); flash_ctx .join_handles -- cgit v1.2.3