Re: [PATCH] rust: devres: add 'static bound to Devres<T>
From: Danilo Krummrich
Date: Wed May 27 2026 - 14:27:24 EST
On Wed May 27, 2026 at 8:07 PM CEST, Gary Guo wrote:
> On Wed May 27, 2026 at 7:04 PM BST, Danilo Krummrich wrote:
>> On Wed May 27, 2026 at 4:44 PM CEST, Gary Guo wrote:
>>> On Tue May 26, 2026 at 1:04 AM BST, Danilo Krummrich wrote:
>>>> Add a 'static bound to prevent storing types with borrowed data in
>>>> Devres.
>>>
>>> The bound should be added on `Devres::new` instead.
>>
>> I did consider this as it is generally recommended to minimize bounds on
>> structs.
>>
>> However, a Devres<T> with non-'static T is semantically nonsensical, not just
>> unconstructible, and I think type level bound represents that better.
>
> Technically `Devres` can contain references to the registration, which is known
> to outlive the bound device.
That's technically true, but how would you express "outlives the device" as a
lifetime bound on Devres?
Additionally, if the borrowed data outlives the device bound, you don't need
device-managed revocation for it in the first place.