Re: [PATCH 1/4] rust: revocable: support fallible PinInit types
From: Danilo Krummrich
Date: Thu Jun 12 2025 - 12:21:49 EST
On Thu, Jun 12, 2025 at 06:17:40PM +0200, Benno Lossin wrote:
> On Thu Jun 12, 2025 at 5:58 PM CEST, Danilo Krummrich wrote:
> > On Thu, Jun 12, 2025 at 05:48:36PM +0200, Benno Lossin wrote:
> >> On Thu Jun 12, 2025 at 4:51 PM CEST, Danilo Krummrich wrote:
> >> > diff --git a/rust/kernel/revocable.rs b/rust/kernel/revocable.rs
> >> > index fa1fd70efa27..41b8fe374af6 100644
> >> > --- a/rust/kernel/revocable.rs
> >> > +++ b/rust/kernel/revocable.rs
> >> > @@ -82,8 +82,11 @@ unsafe impl<T: Sync + Send> Sync for Revocable<T> {}
> >> >
> >> > impl<T> Revocable<T> {
> >> > /// Creates a new revocable instance of the given data.
> >> > - pub fn new(data: impl PinInit<T>) -> impl PinInit<Self> {
> >> > - pin_init!(Self {
> >> > + pub fn new<E>(data: impl PinInit<T, E>) -> impl PinInit<Self, Error>
> >> > + where
> >> > + Error: From<E>,
> >>
> >> I don't think we need this bound as you don't use it in the function
> >> body.
> >
> > I think it's needed by try_pin_init!() below, no?
> >
> > Without it I get the compilation error in [1].
> >
> >> > + {
> >> > + try_pin_init!(Self {
> >> > is_available: AtomicBool::new(true),
> >> > data <- Opaque::pin_init(data),
> >> > })
>
> Does it work with this?
>
> try_pin_init!(Self {
> is_available: AtomicBool::new(true),
> data <- Opaque::pin_init(data),
> }? E)
Yes, it does -- thanks!