From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Yury Norov" <yury.norov@gmail.com>,
"Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>
Cc: "Alexandre Courbot" <acourbot@nvidia.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Joel Fernandes" <joelagnelf@nvidia.com>,
"Jesung Yang" <y.j3ms.n@gmail.com>,
"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>,
"Trevor Gross" <tmgross@umich.edu>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH 1/2] rust: add BitInt integer wrapping type
Date: Mon, 03 Nov 2025 23:44:20 +0900 [thread overview]
Message-ID: <DDZ51VBAJJ5X.2V6GT3H8O1MM@nvidia.com> (raw)
In-Reply-To: <aQi7e6VgFsqpq1Rn@yury>
On Mon Nov 3, 2025 at 11:26 PM JST, Yury Norov wrote:
> On Mon, Nov 03, 2025 at 03:10:01PM +0100, Miguel Ojeda wrote:
>> On Mon, Nov 3, 2025 at 3:17 AM Yury Norov <yury.norov@gmail.com> wrote:
>> >
>> > Rust _must_ do the same thing to at least be arithmetically
>> > compatible to the big brother.
>>
>> No, Rust doesn't need to do anything of the sort, sorry.
>>
>> The point here is not to copy what C does, but to improve on it.
>>
>> In particular, we definitely do not want to have anything like integer
>> promotions and arithmetic conversions from C.
>
> This is exactly what the patch does:
>
> +/// let v = BitInt::<u8, 4>::from_expr(15);
> +///
> +/// // Common operations are supported against the backing type.
> +/// assert_eq!(v + 5, 20);
> +/// assert_eq!(v / 3, 5);
That's incorrect. `v` is backed by a u8, thus the RHS `5` is also a u8
(and so is the result, `20`).
next prev parent reply other threads:[~2025-11-03 14:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-31 13:39 [PATCH 0/2] rust: add BitInt type and use in Nova's bitfield macro Alexandre Courbot
2025-10-31 13:39 ` [PATCH 1/2] rust: add BitInt integer wrapping type Alexandre Courbot
2025-11-02 5:46 ` Alexandre Courbot
2025-11-03 2:17 ` Yury Norov
2025-11-03 10:47 ` Alice Ryhl
2025-11-03 14:31 ` Alexandre Courbot
2025-11-03 13:42 ` Alexandre Courbot
2025-11-03 13:57 ` Alexandre Courbot
2025-11-03 14:01 ` Danilo Krummrich
2025-11-03 19:36 ` Yury Norov
2025-11-04 3:13 ` Alexandre Courbot
2025-11-04 19:30 ` Yury Norov
2025-11-04 20:21 ` Danilo Krummrich
2025-11-05 14:03 ` Alexandre Courbot
2025-11-05 15:45 ` Yury Norov
2025-11-03 14:10 ` Miguel Ojeda
2025-11-03 14:26 ` Yury Norov
2025-11-03 14:44 ` Alexandre Courbot [this message]
2025-11-03 14:54 ` Miguel Ojeda
2025-11-03 19:43 ` Yury Norov
2025-11-03 20:00 ` Yury Norov
2025-10-31 13:39 ` [PATCH FOR REFERENCE 2/2] gpu: nova-core: use BitInt for bitfields 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=DDZ51VBAJJ5X.2V6GT3H8O1MM@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=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=y.j3ms.n@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).