denoland / deno_core

The core engine at the heart of Deno
MIT License
233 stars 76 forks source link

Allow `#[cppgc] &mut T` in sync ops #791

Closed littledivy closed 2 weeks ago

littledivy commented 2 weeks ago

Allow #[cppgc] _: &mut T and #[cppgc] _: Option<&mut T>

Closes https://github.com/denoland/deno_core/issues/787

Trying to use it with async op gives a compiler error:

error[E0308]: mismatched types
    --> core/runtime/ops.rs:1911:3
     |
1911 |   #[op2(async)]
     |   ^^^^^^^^^^^^^
     |   |
     |   types differ in mutability
     |   arguments to this function are incorrect
     |
     = note: expected mutable reference `&mut TestResource`
                        found reference `&TestResource`
note: associated function defined here
    --> core/runtime/ops.rs:1911:3
     |
1911 |   #[op2(async)]
     |   ^^^^^^^^^^^^^
1912 |   pub async fn op_test_set_cppgc_resource(#[cppgc] resource: &mut TestResource, value: u32) {