From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Filipe Xavier <felipe_life@live.com>
Cc: "ojeda@kernel.org" <ojeda@kernel.org>,
"rust-for-linux@vger.kernel.org"
<rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH v3] rust: optimize error type to use nonzero
Date: Sat, 5 Oct 2024 19:50:03 +0200 [thread overview]
Message-ID: <CANiq72kbSsRr3bb5C5ZfgM=-+4mbOG9S-+cu2f0F7vpa95cuzg@mail.gmail.com> (raw)
In-Reply-To: <BL0PR02MB4914E5DB9A7D8AAB13120D3DE9732@BL0PR02MB4914.namprd02.prod.outlook.com>
On Sat, Oct 5, 2024 at 7:14 PM Filipe Xavier <felipe_life@live.com> wrote:
>
> Before the macro doesn't use unsafe anywhere, but now i need call a
> `NonZeroI32::new_unchecked`, i added the `build_assert!` to ensure
> that the macro is safe, and improve the safety comment.
Yeah, that is good, what I was saying is that the compiler should be
able to catch that case during CTFE (although I think it does not
guarantee it in the general case, but I don't know if it does in a
case like this). So I was curious.
> It's possible, but i don't like how it ends up with EINVAL instead of a
> compilation failure when passed an incorrect value.
Not necessarily -- you can return an `Option<Error>`, for instance,
from that new constructor.
(You may find that you want `feature(const_option)`; but you could do
it manually in a stable way too).
Cheers,
Miguel
next prev parent reply other threads:[~2024-10-05 17:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-03 23:16 [PATCH v3] rust: optimize error type to use nonzero Filipe Xavier
2024-10-03 23:23 ` Miguel Ojeda
2024-10-04 11:50 ` Filipe Xavier
2024-10-04 12:57 ` Miguel Ojeda
2024-10-05 17:14 ` Filipe Xavier
2024-10-05 17:50 ` Miguel Ojeda [this message]
2024-10-05 18:52 ` Filipe Xavier
2024-10-05 19:03 ` Miguel Ojeda
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='CANiq72kbSsRr3bb5C5ZfgM=-+4mbOG9S-+cu2f0F7vpa95cuzg@mail.gmail.com' \
--to=miguel.ojeda.sandonis@gmail.com \
--cc=felipe_life@live.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
/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).