From: "Benno Lossin" <lossin@kernel.org>
To: "Danilo Krummrich" <dakr@kernel.org>
Cc: <gregkh@linuxfoundation.org>, <rafael@kernel.org>,
<ojeda@kernel.org>, <alex.gaynor@gmail.com>,
<boqun.feng@gmail.com>, <gary@garyguo.net>,
<bjorn3_gh@protonmail.com>, <benno.lossin@proton.me>,
<a.hindborg@kernel.org>, <aliceryhl@google.com>,
<tmgross@umich.edu>, <rust-for-linux@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/4] rust: revocable: support fallible PinInit types
Date: Thu, 12 Jun 2025 18:17:40 +0200 [thread overview]
Message-ID: <DAKOUVS4YP4L.3I6FD9JKN02EU@kernel.org> (raw)
In-Reply-To: <aEr5FNDaueo5SG5R@cassiopeiae>
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)
---
Cheers,
Benno
>>
>
> [1]
>
> error[E0277]: `?` couldn't convert the error to `error::Error`
> --> rust/kernel/revocable.rs:87:9
> |
> 87 | / try_pin_init!(Self {
> 88 | | is_available: AtomicBool::new(true),
> 89 | | data <- Opaque::pin_init(data),
> 90 | | })
> | | ^
> | | |
> | |__________this can't be annotated with `?` because it has type `Result<_, E>`
> | the trait `core::convert::From<E>` is not implemented for `error::Error`
> |
> = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
> = note: required for `core::result::Result<revocable::Revocable<T>::new::__InitOk, error::Error>` to implement `core::ops::FromResidual<core::result::Result<core::convert::Infallible, E>>`
> = note: this error originates in the macro `$crate::__init_internal` which comes from the expansion of the macro `try_pin_init` (in Nightly builds, run with -Z macro-backtrace for more info)
> help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
> |
> 83 | impl<T> Revocable<T> where error::Error: core::convert::From<E> {
> | ++++++++++++++++++++++++++++++++++++++++++
>
> error[E0277]: the trait bound `impl PinInit<Revocable<T>, Error>: PinInit<Revocable<T>, E>` is not satisfied
> --> rust/kernel/revocable.rs:85:48
> |
> 85 | pub fn new<E>(data: impl PinInit<T, E>) -> impl PinInit<Self, E>
> | ^^^^^^^^^^^^^^^^^^^^^ the trait `pin_init::PinInit<revocable::Revocable<T>, E>` is not implemented for `impl pin_init::PinInit<revocable::Revocable<T>, error::Error>`
> |
> = help: the following other types implement trait `pin_init::PinInit<T, E>`:
> `core::result::Result<T, E>` implements `pin_init::PinInit<T, E>`
> `pin_init::ChainInit<I, F, T, E>` implements `pin_init::PinInit<T, E>`
> `pin_init::ChainPinInit<I, F, T, E>` implements `pin_init::PinInit<T, E>`
> `pin_init::__internal::AlwaysFail<T>` implements `pin_init::PinInit<T, ()>`
> = note: the full name for the type has been written to 'kernel.long-type-441004638990533407.txt'
> = note: consider using `--verbose` to print the full type name to the console
next prev parent reply other threads:[~2025-06-12 16:17 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-12 14:51 [PATCH 0/4] Improvements for Devres Danilo Krummrich
2025-06-12 14:51 ` [PATCH 1/4] rust: revocable: support fallible PinInit types Danilo Krummrich
2025-06-12 15:48 ` Benno Lossin
2025-06-12 15:58 ` Danilo Krummrich
2025-06-12 16:17 ` Benno Lossin [this message]
2025-06-12 16:20 ` Danilo Krummrich
2025-06-12 14:51 ` [PATCH 2/4] rust: devres: replace Devres::new_foreign_owned() Danilo Krummrich
2025-06-13 3:14 ` Viresh Kumar
2025-06-21 21:10 ` Benno Lossin
2025-06-21 21:45 ` Danilo Krummrich
2025-06-22 7:42 ` Benno Lossin
2025-06-22 9:55 ` Danilo Krummrich
2025-06-22 20:18 ` Benno Lossin
2025-06-12 14:51 ` [PATCH 3/4] rust: devres: get rid of Devres' inner Arc Danilo Krummrich
2025-06-22 7:05 ` Benno Lossin
2025-06-22 12:08 ` Danilo Krummrich
2025-06-22 20:16 ` Benno Lossin
2025-06-22 15:45 ` Danilo Krummrich
2025-06-22 20:15 ` Benno Lossin
2025-06-12 14:51 ` [PATCH 4/4] rust: devres: implement register_foreign_release() Danilo Krummrich
2025-06-22 7:26 ` Benno Lossin
2025-06-22 12:46 ` Danilo Krummrich
2025-06-22 20:14 ` Benno Lossin
2025-06-22 20:25 ` Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DAKOUVS4YP4L.3I6FD9JKN02EU@kernel.org \
--to=lossin@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).