Rust for Linux List
 help / color / mirror / Atom feed
From: Gary Guo <gary@garyguo.net>
To: "Eliot Courtney" <ecourtney@nvidia.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"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>
Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	 Gary Guo <gary@garyguo.net>
Subject: [PATCH v2 0/3] rust: const_eval: add a mechanism to do const trait calls
Date: Thu, 03 Sep 2026 16:21:43 +0100	[thread overview]
Message-ID: <20260903-cv-v2-0-e93b1613e40c@garyguo.net> (raw)

Add a mechanism to perform const trait method calls, with the same type
inference capabilities. This would only work for concrete types (not inside
generic functions).

As an example, convert `as_char_ptr_in_const_context`, so instead of

    kernel::str::as_char_ptr_in_const_context(c_str)

one may write

    const_call!(c_str.as_char_ptr())

instead.

Signed-off-by: Gary Guo <gary@garyguo.net>
---
Changes in v2:
- Split from `cv!()` alt series, and become a general infra instead.
- Link to v1: https://patch.msgid.link/20260828-cv-v1-0-694a695ff17f@garyguo.net

---
Gary Guo (3):
      rust: const_eval: add `#[const_eval_only]` attribute
      rust: const_eval: allow const trait method invocation in some contexts
      rust: str: convert `as_char_ptr` to work with `const_call!`

 rust/build_error.rs       |   7 +++
 rust/kernel/configfs.rs   |   2 +-
 rust/kernel/const_eval.rs | 115 ++++++++++++++++++++++++++++++++++++++++++++++
 rust/kernel/device_id.rs  |   4 ++
 rust/kernel/drm/device.rs |   4 +-
 rust/kernel/drm/ioctl.rs  |   4 +-
 rust/kernel/kunit.rs      |   6 +--
 rust/kernel/lib.rs        |   1 +
 rust/kernel/miscdevice.rs |   2 +-
 rust/kernel/net/phy.rs    |   2 +-
 rust/kernel/prelude.rs    |   1 +
 rust/kernel/str.rs        |  15 +++---
 rust/macros/const_eval.rs |  51 ++++++++++++++++++++
 rust/macros/lib.rs        |  39 ++++++++++++++++
 rust/macros/module.rs     |   4 +-
 15 files changed, 237 insertions(+), 20 deletions(-)
---
base-commit: 89c07d98716a13454ec3fd9f97689e812cc71bd4
change-id: 20260828-cv-acaf3400d16c

Best regards,
--  
Gary Guo <gary@garyguo.net>


             reply	other threads:[~2026-09-03 15:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 15:21 Gary Guo [this message]
2026-09-03 15:21 ` [PATCH v2 1/3] rust: const_eval: add `#[const_eval_only]` attribute Gary Guo
2026-09-03 15:21 ` [PATCH v2 2/3] rust: const_eval: allow const trait method invocation in some contexts Gary Guo
2026-09-03 15:21 ` [PATCH v2 3/3] rust: str: convert `as_char_ptr` to work with `const_call!` Gary Guo
2026-09-03 15:34 ` [PATCH v2 0/3] rust: const_eval: add a mechanism to do const trait calls Miguel Ojeda
2026-09-03 15:46   ` Gary Guo

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=20260903-cv-v2-0-e93b1613e40c@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=ecourtney@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /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