From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
"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>,
"Alice Ryhl" <aliceryhl@google.com>,
"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 RESEND] rust: enable slice_flatten feature and abstract it through an extension trait
Date: Sun, 02 Nov 2025 11:25:03 +0900 [thread overview]
Message-ID: <DDXUPAELH6C2.3JK5JVGP87V8N@nvidia.com> (raw)
In-Reply-To: <CANiq72n6KLjA5XQmAhy=SRTnWY8sCCmp9ETnB-dTSVZ84-mjzw@mail.gmail.com>
On Sun Nov 2, 2025 at 12:36 AM JST, Miguel Ojeda wrote:
> On Sat, Nov 1, 2025 at 2:32 PM Alexandre Courbot <acourbot@nvidia.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@kernel.org>
>
> Otherwise, I will pick it up.
Thanks!
>
>> +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.
Ah, I think I see what you mean. The `slice_flatten` feature has been
removed in 1.80 with the stabilization and method rename, so I guess we
would have to do something like:
config RUSTC_HAS_SLICE_FLATTEN
def_bool RUSTC_VERSION < 108000
... and invert the logic in the code. That would run contrary to the
other `RUSTC_HAS` options requiring at least a given version though.
Also not all of these seem to be tied to a feature;
`RUSTC_HAS_FILE_AS_C_STR` appears to refer to the
`Location::file_as_c_str` method, which is behind the `file_with_nul`
feature.
So I guess `config RUST_HAS_AS_FLATTENED` would also work. I'm happy to
follow what you think is best here. :)
>
>> +/// 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).
The funny thing is that I intented to copy the Rust doc for
`as_flattened`, but failed to even copy/paste it properly! ^_^; Fixed,
thanks.
next prev parent reply other threads:[~2025-11-02 2:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-01 13:31 [PATCH RESEND] rust: enable slice_flatten feature and abstract it through an extension trait Alexandre Courbot
2025-11-01 15:36 ` Miguel Ojeda
2025-11-02 2:25 ` Alexandre Courbot [this message]
2025-11-02 12:00 ` Miguel Ojeda
2025-11-02 14:28 ` Alexandre Courbot
2025-11-01 15:52 ` Danilo Krummrich
2025-11-03 10:22 ` Alice Ryhl
2025-11-03 15:06 ` Alexandre Courbot
2025-11-04 8:37 ` Alice Ryhl
2025-11-04 10:57 ` 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=DDXUPAELH6C2.3JK5JVGP87V8N@nvidia.com \
--to=acourbot@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.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=miguel.ojeda.sandonis@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).