Rust for Linux List
 help / color / mirror / Atom feed
From: Nika Krasnova <nika@nikableh.moe>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "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>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Yury Norov" <yury.norov@gmail.com>,
	"Lorenzo Stoakes" <ljs@kernel.org>,
	"Brendan Higgins" <brendan.higgins@linux.dev>,
	"David Gow" <david@davidgow.net>,
	"Rae Moar" <raemoar63@gmail.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 0/2] rust: kernel: add cfg_select! and use it for config-based selection
Date: Mon, 29 Jun 2026 17:34:05 +0200	[thread overview]
Message-ID: <0eb77f4b7199e9af01d61e0c1ac03c99@purelymail.com> (raw)
In-Reply-To: <CANiq72kG8k3mk+Xjr6q7aKg212QUNtZk5w4rxV=UGR5UXKE_ng@mail.gmail.com>

On 2026-06-29 11:38:22 +0200, Miguel Ojeda wrote:
> For instance, instead of waiting for the MSRV bump, could we already
> use the upstream one since Rust 1.91.0? That means that we are already
> sure we are using the upstream one as-is.
> 
> Or is there a reason to avoid that?

There is one, yes. First the toolchain picture (tested with
RUSTC_BOOTSTRAP=1):

  - 1.85.0 (current MSRV): core::cfg_select does not exist -- only the 
older
    core::cfg_match (old `cfg(...)` arm syntax).
  - 1.94.1: core::cfg_select present behind #![feature(cfg_select)], with
    the final builtin behavior (single-brace expression position works).
  - 1.95.0: core::cfg_select stable.

A gate (upstream when available, fallback when not) is possible, but 
unlike
the cold_path case the fallback isn't a drop-in replacement. In item and
statement position the two are identical (single braces), but in pure
expression-operand position they are mutually exclusive: the builtin 
takes
single braces, while the macro_rules needs an extra pair
(cfg_select! {{ ... }}), since it cannot put #[cfg] on a bare expression
without stmt_expr_attributes. No single spelling compiles on both.

That means a gate would force prohibiting expression-operand position
entirely (no portable spelling), which I would rather not do. I would
prefer to keep the macro_rules everywhere -- one consistent macro on 
every
toolchain, expression position included -- and switch wholesale to
core::cfg_select once the MSRV reaches a version that has it. The switch 
is
cheap: item/statement call sites are unchanged, and the only edit is
dropping the extra braces at any expression-position sites (there are 
none
in the tree today).

I will still move it into std_vendor.rs and align the docs with 
upstream's,
keeping the expression-position note since that is the one real 
difference.

Does that work for you, or would you rather take the gate and drop
expression-operand support?

-- 
Nika Krasnova

  parent reply	other threads:[~2026-06-29 15:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29  3:51 [PATCH 0/2] rust: kernel: add cfg_select! and use it for config-based selection Nika Krasnova
2026-06-29  3:51 ` [PATCH 1/2] rust: kernel: add cfg_select! backport " Nika Krasnova
2026-06-29  3:51 ` [PATCH 2/2] rust: kernel: migrate to cfg_select! " Nika Krasnova
2026-06-29  9:38 ` [PATCH 0/2] rust: kernel: add cfg_select! and use it " Miguel Ojeda
2026-06-29  9:43   ` Miguel Ojeda
2026-06-29 15:34   ` Nika Krasnova [this message]
2026-06-29 19:07     ` Miguel Ojeda
2026-07-01  1:39       ` Nika Krasnova

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=0eb77f4b7199e9af01d61e0c1ac03c99@purelymail.com \
    --to=nika@nikableh.moe \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=brendan.higgins@linux.dev \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=david@davidgow.net \
    --cc=gary@garyguo.net \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=lossin@kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=raemoar63@gmail.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=viresh.kumar@linaro.org \
    --cc=work@onurozkan.dev \
    --cc=yury.norov@gmail.com \
    /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