[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72n6KLjA5XQmAhy=SRTnWY8sCCmp9ETnB-dTSVZ84-mjzw@mail.gmail.com>
Date: Sat, 1 Nov 2025 16:36:13 +0100
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Alexandre Courbot <acourbot@...dia.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>, Nathan Chancellor <nathan@...nel.org>,
Nicolas Schier <nicolas.schier@...ux.dev>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-kbuild@...r.kernel.org
Subject: Re: [PATCH RESEND] rust: enable slice_flatten feature and abstract it
through an extension trait
On Sat, Nov 1, 2025 at 2:32 PM Alexandre Courbot <acourbot@...dia.com> wrote:
>
> Hopefully it captures Miguel's suggestion [2] accurately, but please let
> me know if I missed something.
Yeah, this is what I meant and looks great -- thanks!
If you need to use it this cycle in another branch:
Acked-by: Miguel Ojeda <ojeda@...nel.org>
Otherwise, I will pick it up.
> +config RUSTC_HAS_SLICE_AS_FLATTENED
I guess you used this one since they renamed it and since we don't use
the `alloc` method. It is fine, both options are confusing in
different ways, but sometimes the feature name is the only one that
can be used (since it may enable several methods etc.), so I wonder if
we should try to use that consistently.
> +/// In Rust 1.80, the previously unstable `slice::flatten` family of methods
> +/// have been stabilized and renamed from `flatten` to `as_flattened`.
> +///
> +/// This creates an issue for as long as the MSRV is < 1.80, as the same functionality is provided
> +/// by different methods depending on the compiler version.
> +///
> +/// This extension trait solves this by abstracting `as_flatten` and calling the correct method
> +/// depending on the Rust version.
> +///
> +/// This trait can be removed once the MSRV passes 1.80.
These paragraphs sound like implementations details -- I would
probably leave that to the commit message or normal comments instead
(we should notice we need to remove these thanks to the line in
`Kconfig` already).
Nit: two spaces above.
> + /// Takes an `&[[T; N]]` and flattens it to a `&[T]`.
Nit: I don't know how one is supposed to pronounce these, but I guess
it is "a" in the first one, like the second one (the upstream docs
also do that).
By the way, it crossed my mind that we may want to use `#[doc(alias =
"...")` here to guide search, but I guess not many developers are
using local/older versions and this will go away soon anyway.
Cheers,
Miguel
Powered by blists - more mailing lists