public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>
Cc: "Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Lorenzo Stoakes" <lorenzo.stoakes@oracle.com>,
	"Vlastimil Babka" <vbabka@suse.cz>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	"Uladzislau Rezki" <urezki@gmail.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: alloc: allow different error types in `KBox::pin_slice`
Date: Mon, 16 Feb 2026 10:37:08 +0100	[thread overview]
Message-ID: <DGGA9UY5W4XM.1QXWP29ZW1YKE@kernel.org> (raw)
In-Reply-To: <aZLZ69umB8rA2La2@google.com>

On Mon Feb 16, 2026 at 9:48 AM CET, Alice Ryhl wrote:
> On Sat, Feb 14, 2026 at 03:56:43PM +0100, Danilo Krummrich wrote:
>> Yeah, but isn't this only because of [1], which does not apply to the kernel
>> because our minimum compiler version is 1.78 anyways?
>> 
>> I.e. are there any cases where we can't implement From in the kernel and have to
>> fall back to Into?
>
> Probably not, but it's still best practice to use Into over From when
> specifying trait bounds.

I'm aware; my point is that I'm questioning this best practice in the context of
a modern and self-contained project like Rust in the kernel.

This patch is a very good example, as there seem to be zero downsides to a From
trait bound, while using the From trait bound allows for cleaner code.

(I.e. we get rid of the matches and can use the '?' operator instead. To be
fair, this could also be written as `.map_err(Into::into)?`, but still.)

I'd even argue that using a From trait bound here is a feature and not a
limitation. I.e. if someone would pass something that implements Into (but not
From) we'd catch it and can tell the caller to implement From instead of Into,
which is preferred and should always be possible in the kernel.

  reply	other threads:[~2026-02-16  9:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-14 13:28 [PATCH] rust: alloc: allow different error types in `KBox::pin_slice` Andreas Hindborg
2026-02-14 13:37 ` Andreas Hindborg
2026-02-14 14:17 ` Danilo Krummrich
2026-02-14 14:40   ` Benno Lossin
2026-02-14 14:56     ` Danilo Krummrich
2026-02-15 23:29       ` Benno Lossin
2026-02-16  8:48       ` Alice Ryhl
2026-02-16  9:37         ` Danilo Krummrich [this message]
2026-02-27 14:38       ` Gary Guo
2026-02-14 14:37 ` Benno Lossin

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=DGGA9UY5W4XM.1QXWP29ZW1YKE@kernel.org \
    --to=dakr@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=urezki@gmail.com \
    --cc=vbabka@suse.cz \
    /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