On Mon Sep 28, 2026 at 1:15 PM BST, Danilo Krummrich wrote:
> On Mon Sep 28, 2026 at 2:10 PM CEST, Gary Guo wrote:
>> On Mon Sep 28, 2026 at 1:00 PM BST, Danilo Krummrich wrote:
>>> On Mon Sep 28, 2026 at 1:36 PM CEST, Gary Guo wrote:
>>>> I think this doesn't need to use `pin_chain`? You can do
>>>>
>>>>     gpu <- ...,
>>>>
>>>>     _: {
>>>>         #[cfg(...)]
>>>>         gpu.run_self_tests(pdev);
>>>>     }
>>>
>>> Unfortunately, this produces the following error.
>>>
>>>     error[E0382]: borrow of moved value: `gpu`
>>>        --> drivers/gpu/nova-core/driver.rs:140:62
>>>         |
>>>     119 |             gpu <- Gpu::new(
>>>         |             --- move occurs because `gpu` has type 
>>> `core::pin::Pin<&mut gpu::Gpu<'_>>`, which does not implement the `Copy` 
>>> trait
>>>     ...
>>>     129 |                 gpu.run_selftests(pdev);
>>>         |                 --- value moved here
>>
>>     gpu.as_mut().run_selftests(pdev);
>>
>> should work?
>
> I tried that previously, that gives another error. I didn't dig in further
> though.
>
>       error[E0596]: cannot borrow `gpu` as mutable, as it is not declared as 
> mutable
>          --> drivers/gpu/nova-core/driver.rs:129:17
>           |
>       129 |                 gpu.as_mut().run_selftests(pdev);
>           |                 ^^^ cannot borrow as mutable
>           |
>       help: consider changing this to be mutable
>           |
>       119 |             mut gpu <- Gpu::new(
>           |             +++
>       
>       error: aborting due to 1 previous error

Right, we didn't create the let binding with `mut`.

Does this fix it for you?

diff --git a/rust/pin-init/internal/src/init.rs 
b/rust/pin-init/internal/src/init.rs
index c5b5a0ce5c4e..031adb46cefe 100644
--- a/rust/pin-init/internal/src/init.rs
+++ b/rust/pin-init/internal/src/init.rs
@@ -446,7 +446,7 @@ fn init_fields(fields: &Punctuated<InitializerField, 
Token![,]>, pinned: bool) -
                 // Allow `non_snake_case` since the same warning is going to 
be reported for the
                 // struct field.
                 #[allow(unused_variables, non_snake_case)]
-                let #ident = #guard.let_binding();
+                let mut #ident = #guard.let_binding();
             },
             Member::Unnamed(_) => quote!(),
         };

Best,
Gary

Reply via email to