On Mon Jul 13, 2026 at 9:29 PM BST, Danilo Krummrich wrote:
> On Mon Jul 13, 2026 at 10:14 PM CEST, Gary Guo wrote:
>> diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
>> index b3c91731db45..b603b0bd2692 100644
>> --- a/drivers/gpu/nova-core/gpu.rs
>> +++ b/drivers/gpu/nova-core/gpu.rs
>> @@ -285,10 +285,10 @@ pub(crate) struct Gpu<'gpu> {
>>  }
>>  
>>  impl<'gpu> Gpu<'gpu> {
>> -    pub(crate) fn new(
>> -        pdev: &'gpu pci::Device<device::Core<'_>>,
>> +    pub(crate) fn new<'a>(
>> +        pdev: &'gpu pci::Device<device::Core<'a>>,
>>          bar: Bar0<'gpu>,
>> -    ) -> impl PinInit<Self, Error> + 'gpu {
>> +    ) -> impl PinInit<Self, Error> + use<'gpu, 'a> {
>
> Isn't that edition 2024 only?

The syntax is available to all editions. Pre-2024 only type parameters are
captured, so the `use` would be needed to capture `'a`.

In 2024 the capture rule is changed so that all lifetimes are captured by
default, removing the inconsistency between lifetime and type parameters, so
this can just be 

    pub(crate) fn new(
        pdev: &'gpu pci::Device<device::Core<'_>>,
        bar: Bar0<'gpu>,
    ) -> impl PinInit<Self, Error> {

The equivalent code without using `use` is

    pub(crate) fn new<'init, 'a>(
        pdev: &'gpu pci::Device<device::Core<'a>>,
        bar: Bar0<'gpu>,
    ) -> impl PinInit<Self, Error> + 'init where 'init: 'gpu, 'init: 'a {

but `use` is stable in 1.82+ so we can just use it instead.

>
>>          try_pin_init!(Self {
>>              device: pdev.as_ref(),
>>              spec: Spec::new(pdev.as_ref(), bar).inspect(|spec| {
>
> I think you also need this hunk:
>
> diff --git a/samples/rust/rust_debugfs.rs b/samples/rust/rust_debugfs.rs
> index 1f59e08aaa4b..6fe94a73c52a 100644
> --- a/samples/rust/rust_debugfs.rs
> +++ b/samples/rust/rust_debugfs.rs
> @@ -147,7 +147,7 @@ fn build_inner(dir: &Dir) -> impl 
> PinInit<File<Mutex<Inner>>> + '_ {
>          dir.read_write_file(c"pair", new_mutex!(Inner { x: 3, y: 10 }))
>      }
>
> -    fn new<'a>(pdev: &'a platform::Device<Core<'_>>) -> impl PinInit<Self, 
> Error> + 'a {
> +    fn new<'a, 'b>(pdev: &'a platform::Device<Core<'b>>) -> impl 
> PinInit<Self, Error> + use<'a, 'b> {
>          let debugfs = Dir::new(c"sample_debugfs");
>          let dev = pdev.as_ref();

Right, somehow debugfs is disabled in my test build that I didn't notice.

Best,
Gary

Reply via email to