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

Alexandre Courbot
2026-04-30T11:35:20Z

On Thu Apr 30, 2026 at 6:14 PM JST, 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?

Good idea, it's not obvious what this lifetime covers at first sight.
I'd even hammer it a bit more in the documentation as it is quite an
essential point.