deno_core icon indicating copy to clipboard operation
deno_core copied to clipboard

Op that takes handle scope and a cppgc argument doesn't compile with `#[op2(fast)]`

Open nathanwhit opened this issue 5 months ago • 0 comments

Repro

pub struct Foo;
impl deno_core::GarbageCollected for Foo {}
#[op2(fast)]
pub fn op_repro(_scope: &mut v8::HandleScope, #[cppgc] _foo: &Foo) {}

Fails to compile with

error[E0502]: cannot borrow `*fast_api_callback_options.isolate` as mutable because it is also borrowed as immutable
   --> repro/main.rs:3:1
    |
3 | #[op2(fast)]
    | ^^^^^^^^^^^-
    | |          |
    | |          immutable borrow might be used here, when `scope` is dropped and runs the `Drop` code for type `CallbackScope`
    | mutable borrow occurs here
    | immutable borrow occurs here
    |
    = note: this error originates in the attribute macro `op2` (in Nightly builds, run with -Z macro-backtrace for more info)

If you remove the fast attr, then op2 errors with This op is fast-compatible and should be marked as (fast).

The only way to get it to compile is with the nofast attr.

nathanwhit avatar Sep 09 '24 22:09 nathanwhit