Re: [PATCH 00/24] rust: device: Higher-Ranked Lifetime Types for device drivers

Danilo Krummrich
2026-04-30T13:36:18Z

On Thu Apr 30, 2026 at 11:14 AM CEST, Alice Ryhl wrote:
> Super cool to see this!
>
> On Tue, Apr 28, 2026 at 12:10:58AM +0200, Danilo Krummrich wrote:
>> Before:
>>
>> struct MyDriver {
>> pdev: ARef<pci::Device>,
>> bar: Devres<pci::Bar<BAR_SIZE>>,
>> }
>>
>> let io = self.bar.access(dev)?;
>> io.read32(OFFSET);
>>
>> After:
>>
>> struct MyDriver<'a> {
>> pdev: &'a pci::Device,
>> bar: pci::Bar<'a, BAR_SIZE>,
>> }
>>
>> self.bar.read32(OFFSET);
>
> I think we should establish a convention for how to name the lifetime
> early. Using just the generic name 'a is probably not ideal.
>
> How about using 'dev for lifetimes that correspond to the lifetime of
> the device being bound?

I'd rather not go for 'dev, as it could be confused with the lifetime of the
struct device itself, which is reference counted and independent from the device
/ driver binding lifecycle.

People already confuse this all the time, so I'd rather go for 'bound, which is
more precise, but could be a bit long on the other hand.