From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>
Cc: "Eliot Courtney" <ecourtney@nvidia.com>,
"Yury Norov" <yury.norov@gmail.com>,
"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>,
"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 v4 1/2] rust: num: add cv! macro to create values from constant expressions
Date: Fri, 09 Oct 2026 00:02:52 +0900 [thread overview]
Message-ID: <DLZJQQV2BFNE.UQLPM72II2NZ@nvidia.com> (raw)
In-Reply-To: <CANiq72m0PLhT=-ODzQtX7k3jn6=XXpESDUbnHcAmR-1gFqR7uQ@mail.gmail.com>
On Sat Oct 3, 2026 at 1:59 AM JST, Miguel Ojeda wrote:
<...>
> One thing before that, though: are these assertions expected to fail?
>
> const X: i64 = 1 << 31;
> const Y: i64 = cv!(1 << 31);
> assert_eq!(X, Y);
>
> Or:
>
> const X: u64 = 2 << 31;
> const Y: u64 = cv!(2 << 31);
> assert_eq!(X, Y);
I have tested and both fail indeed. However they pass if the `cv!` literal
is annotated with the correct type (e.g. `cv!(1i64 << 31)`).
>
> Because that is quite surprising, especially since we say "with the
> target type inferred from the context" in the documentation.
The target type is indeed inferred, but the expression is typed by
itself, so unsuffixed literals default to `i32` as they would in a `let`
statement without annotation. That limitation is inherent to the design
widening to `i128` I am afraid.
I don't know if that's a blocker, but if not, we should probably have a
`Pitfalls` section to mention that explicitly.
next prev parent reply other threads:[~2026-10-08 15:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 8:34 [PATCH v4 0/2] rust: introduce cv! macro for safe const conversions of integer-like types Eliot Courtney
2026-09-17 8:34 ` [PATCH v4 1/2] rust: num: add cv! macro to create values from constant expressions Eliot Courtney
2026-09-17 8:50 ` Danilo Krummrich
2026-09-29 11:15 ` Alice Ryhl
2026-10-02 16:59 ` Miguel Ojeda
2026-10-08 15:02 ` Alexandre Courbot [this message]
2026-09-17 8:34 ` [PATCH v4 2/2] gpu: nova-core: use cv! for constant casts Eliot Courtney
2026-09-17 8:57 ` Danilo Krummrich
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=DLZJQQV2BFNE.UQLPM72II2NZ@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=miguel.ojeda.sandonis@gmail.com \
--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®