Re: [PATCH v5 01/11] gpu: nova-core: Add public driver API to nova-core
From: Gary Guo
Date: Tue Sep 01 2026 - 07:40:41 EST
On Tue Sep 1, 2026 at 11:27 AM BST, Danilo Krummrich wrote:
> On Mon Aug 31, 2026 at 10:42 PM CEST, Gary Guo wrote:
>> I think if you change the signatue of `registration_data_with` slightly:
>>
>> pub fn registration_data_with<'this, F: ForLt + 'static, R>(
>> &'this self,
>> f: impl for<'a> FnOnce(Pin<&'this F::Of<'a>>) -> R,
>> ^ note this is changed from 'a to 'this
>> ) -> Result<R>;
>>
>> then there will be an implied bound available inside the callback where 'a
>> outlives 'this, and thus the function callback is able to perform coercion of
>> any T<'a> to T<'this> provided that `T` is covariant over lifetime `'a`.
>>
>> [ The coercion won't work when doing abstract `F::Of` on the bus abstraction
>> side, but for any user it is dealing with concrete types so the compiler sees
>> specific types and thus can check variance ]
>>
>> Then your projection can just be
>>
>> aux.registration_data_project(|x| &x.field)
>>
>> I haven't tried it out but I think it should work.
>
> I gave this a shot and it seems to work out, it's a good simplification. I think
> we don't even need a dedicated project method in this case. We could add an
> alias for with() just to clarify the intent, but not sure that's worth.
Right, I don't think it's needed. It's just a typo in the example given that I
write "_project" instead of "_with". Unless you have a case where it actually
needs `&'a F::Of<'a>` instead of `&'this F::Of<'a>` (which I think is not very
likely, changing signatures of existing users should be sufficient), I think we
should just modify the signature of `registration_data_with`.
Best,
Gary