mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Gary Guo" <gary@garyguo.net>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
	"Eliot Courtney" <ecourtney@nvidia.com>,
	"Yury Norov" <yury.norov@gmail.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>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Onur Özkan" <work@onurozkan.dev>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Timur Tabi" <ttabi@nvidia.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 1/3] rust: num: add cv! macro to create values from constant expressions
Date: Mon, 21 Sep 2026 00:04:29 +0900	[thread overview]
Message-ID: <DLK8I686ILHU.2NE50HPZX3Z10@nvidia.com> (raw)
In-Reply-To: <DLK6XHP5NIN4.37W548MAWYF67@garyguo.net>

On Sun Sep 20, 2026 at 10:50 PM JST, Gary Guo wrote:
> On Sun Sep 20, 2026 at 1:38 PM BST, Danilo Krummrich wrote:
>> On Sun Sep 20, 2026 at 2:20 PM CEST, Gary Guo wrote:
>>> On Fri Sep 18, 2026 at 7:03 PM BST, Alexandre Courbot wrote:
>>>> On Thu Sep 17, 2026 at 9:53 AM BST, Gary Guo wrote:
>>>>> On Tue Sep 15, 2026 at 8:39 AM BST, Alexandre Courbot wrote:
>>>>>> On Wed Sep 2, 2026 at 6:16 PM JST, Eliot Courtney wrote:
>>>>>>> Currently, using NonZero/Bounded constants is quite verbose. It's
>>>>>>> unfortunate because it disincentivizes using it in interface boundaries.
>>>>>>> Introduce a macro to make it nicer to use. The macro `cv!` (for constant
>>>>>>> value) takes a const integer expression and widens it to i128 (at build
>>>>>>> time only) before passing it as a const generic value to a new trait
>>>>>>> `FromConst`. The value is then converted and appears in the
>>>>>>> associated constant `FromConst::VALUE`. The trait is implemented by
>>>>>>> NonZero, Bounded, and Alignment and lets values of each be constructed
>>>>>>> from constants without a verbose turbofish syntax.
>>>>>>> For example, `const { NonZero::new(1).unwrap() }` can be written as
>>>>>>> `cv!(1)`.
>>>>>>>
>>>>>>> Suggested-by: Gary Guo <gary@garyguo.net>
>>>>>>> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
>>>>>>
>>>>>> I don't think we have any user but nova-core at the moment, and it
>>>>>> benefits from this in several series (patch 3 here, but also ID pool and
>>>>>> later r000). Miguel, is this ok if we take it (i.e. the next revision)
>>>>>> through drm-rust-next?
>>>>>
>>>>> How about a topic tag shared between Rust and drm-rust-next? We could also
>>>>> remove the old num casts API as part of topic tag and fix all existing users as
>>>>> part of merge.
>>>>
>>>> Not opposed to the idea but IIRC there was already some pushback to the
>>>> idea. There doesn't seem to be an urgency to remove the old num casts
>>>> API that justifies doing it now with a more complicated merge path. 
>>>
>>> Sorry, what pushbacks? I thought that `cv!` is what everyone agrees on. I see no
>>> downside of this compared to the turbofish const conversion APIs.
>>>
>>> I am not opposed to delaying removal for the next cycle, but IMO the `cv!` macro
>>> should be present on Rust tree so it's visible and improvements can be made from
>>> there, so I think we should do a topic tag regardless whether the old API
>>> removal happens or not.
>>
>> I think Alex refers to this thread [1]; there's was some more context to this
>> though.
>
> Right, so "pushback" here relates to the logistics of old API removal, not the
> idea of `cv!`?

Correct - sorry about the confusion.

  reply	other threads:[~2026-09-20 15:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02  9:16 [PATCH v3 0/3] rust: introduce cv! macro for safe const conversions of integer-like types Eliot Courtney
2026-09-02  9:16 ` [PATCH v3 1/3] rust: num: add cv! macro to create values from constant expressions Eliot Courtney
2026-09-02 13:21   ` Gary Guo
2026-09-15  7:39   ` Alexandre Courbot
2026-09-17  7:59     ` Eliot Courtney
2026-09-17  8:53     ` Gary Guo
2026-09-18 18:03       ` Alexandre Courbot
2026-09-20 12:20         ` Gary Guo
2026-09-20 12:38           ` Danilo Krummrich
2026-09-20 13:50             ` Gary Guo
2026-09-20 15:04               ` Alexandre Courbot [this message]
2026-09-02  9:16 ` [PATCH v3 2/3] rust: prelude: add `num::cv` Eliot Courtney
2026-09-15  7:40   ` Alexandre Courbot
2026-09-02  9:16 ` [PATCH v3 3/3] gpu: nova-core: use cv! for constant casts Eliot Courtney

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=DLK8I686ILHU.2NE50HPZX3Z10@nvidia.com \
    --to=acourbot@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nova-gpu@lists.linux.dev \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=ttabi@nvidia.com \
    --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

all inboxes | Powered by JetHome®