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) ``` --- ops/optimizer.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ops/optimizer.rs') diff --git a/ops/optimizer.rs b/ops/optimizer.rs index 17435407c..99de4b424 100644 --- a/ops/optimizer.rs +++ b/ops/optimizer.rs @@ -650,7 +650,9 @@ impl Optimizer { let segment = single_segment(segments)?; match segment { // Is `T` a OpState? - PathSegment { ident, .. } if ident == "OpState" => { + PathSegment { ident, .. } + if ident == "OpState" && !self.is_async => + { self.has_ref_opstate = true; } // Is `T` a str? -- cgit v1.2.3