Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] Small forwarding functions in abstractions are missing `#[inline]` 
annotations.
--

commit 703db32948a8690227e0f13e2618862778e2205c
Author: Danilo Krummrich <[email protected]>

rust: auxiliary: add registration_data_with() for ForLt types

This commit adds registration_data_with() to allow non-covariant ForLt
types to be registered by taking an HRTB closure, avoiding concrete lifetime
selection. It also extracts shared logic into a private
registration_data_pinned() helper and relaxes the Registration bound.

> diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs
> index 40a0af74a8e5c..8013c0fcd82d8 100644
> --- a/rust/kernel/auxiliary.rs
> +++ b/rust/kernel/auxiliary.rs

[ ... ]

> @@ -300,17 +298,57 @@ pub fn registration_data<F: CovariantForLt + 
> 'static>(&self) -> Result<Pin<&F::O

[ ... ]

> +    pub fn registration_data_with<F: ForLt + 'static, R>(
> +        &self,
> +        f: impl for<'a> FnOnce(Pin<&'a F::Of<'a>>) -> R,
> +    ) -> Result<R> {

[Severity: Low]
This isn't a bug, but according to the Rust subsystem guidelines, small or
forwarding functions in abstractions should be annotated with #[inline].
Should this newly added forwarding function have an #[inline] attribute?

> +        // SAFETY: The HRTB closure prevents the caller from smuggling in 
> references with a
> +        // concrete short lifetime, making the round-trip from `'static` 
> sound regardless of
> +        // variance.
> +        let pinned = unsafe { self.registration_data_pinned::<F>()? };
> +
> +        Ok(f(pinned))
> +    }

[ ... ]

> +    pub fn registration_data<F: CovariantForLt + 'static>(&self) -> 
> Result<Pin<&F::Of<'_>>> {

[Severity: Low]
This isn't a bug, but since this function was modified to become a small
forwarding function to registration_data_pinned(), should it also receive
an #[inline] annotation to match the subsystem guidelines?

> +        // SAFETY: `CovariantForLt` guarantees covariance, which makes the 
> lifetime shortening
> +        // from `'static` to `'_` performed by `registration_data_pinned` 
> sound.
> +        unsafe { self.registration_data_pinned::<F>() }
>      }
>  }

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=3

Reply via email to