public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: Alexandre Courbot <acourbot@nvidia.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nicolas.schier@linux.dev>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	linux-kbuild@vger.kernel.org
Subject: Re: [PATCH v2] rust: enable slice_flatten feature and provide it through an extension trait
Date: Tue, 4 Nov 2025 14:35:52 +0000	[thread overview]
Message-ID: <aQoPSH1jyv9DWhsH@google.com> (raw)
In-Reply-To: <DDZZ1ZWIPH8P.3M7H00GIMJUXV@nvidia.com>

On Tue, Nov 04, 2025 at 11:15:03PM +0900, Alexandre Courbot wrote:
> On Tue Nov 4, 2025 at 11:10 PM JST, Alice Ryhl wrote:
> > On Tue, Nov 04, 2025 at 12:53:18PM +0900, Alexandre Courbot wrote:
> >> In Rust 1.80, the previously unstable `slice::flatten` family of methods
> >> have been stabilized and renamed to `slice::as_flattened`.
> >> 
> >> This creates an issue as we want to use `as_flattened`, but need to
> >> support the MSRV (which at the moment is Rust 1.78) where it is named
> >> `flatten`.
> >> 
> >> Solve this by enabling the `slice_flatten` feature, and providing an
> >> `as_flattened` implementation through an extension trait for compiler
> >> versions where it is not available.
> >> 
> >> This lets code use `as_flattened` portably by just adding
> >> 
> >>     #[cfg(not(CONFIG_RUSTC_HAS_SLICE_AS_FLATTENED))]
> >>     use kernel::slice::AsFlattened;
> >> 
> >> This extension trait can be removed once the MSRV passes 1.80.
> >> 
> >> Suggested-by: Miguel Ojeda <ojeda@kernel.org>
> >> Link: https://lore.kernel.org/all/CANiq72kK4pG=O35NwxPNoTO17oRcg1yfGcvr3==Fi4edr+sfmw@mail.gmail.com/
> >> Acked-by: Danilo Krummrich <dakr@kernel.org>
> >> Acked-by: Miguel Ojeda <ojeda@kernel.org>
> >> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> >> ---
> >> This patch was part of the Nova GSP boot series [1], but since it
> >> requires attention from the core Rust team (and possibly the build
> >> maintainers?) and is otherwise buried under Nova patches, I am taking
> >> the freedom to send it separately for visibility.
> >> 
> >> For v2, the methods are aligned with the final names of the standard
> >> library, and the extension trait is only visible when needed. This
> >> simplifies both the patch, and the extra labor for user code.
> >> 
> >> [1] https://lore.kernel.org/all/20251029-gsp_boot-v7-0-34227afad347@nvidia.com/
> >> [2] https://lore.kernel.org/all/CANiq72kK4pG=O35NwxPNoTO17oRcg1yfGcvr3==Fi4edr+sfmw@mail.gmail.com/
> >
> > With the below concern verified, you may add:
> > Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> 
> Thanks! You may want to check the v3 that I just posted [1] which also
> addressed your comment about having the extensions trait in the prelude.
> 
> [1] https://lore.kernel.org/rust-for-linux/20251104-b4-as-flattened-v3-1-6cb9c26b45cd@nvidia.com/T/#u

Looks good thanks.

Alice

  reply	other threads:[~2025-11-04 14:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-04  3:53 [PATCH v2] rust: enable slice_flatten feature and provide it through an extension trait Alexandre Courbot
2025-11-04 14:10 ` Alice Ryhl
2025-11-04 14:15   ` Alexandre Courbot
2025-11-04 14:35     ` Alice Ryhl [this message]
2025-11-04 14:16   ` Miguel Ojeda
2025-11-05  8:10   ` Alexandre Courbot

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=aQoPSH1jyv9DWhsH@google.com \
    --to=aliceryhl@google.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nicolas.schier@linux.dev \
    --cc=ojeda@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