From: Alvin Sun <alvin.sun@linux.dev>
To: "Gary Guo" <gary@garyguo.net>, "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>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Daniel Almeida" <daniel.almeida@collabora.com>
Cc: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 03/13] rust: sync: set_once: Rename InitError variants to fix clippy warning
Date: Fri, 27 Mar 2026 14:07:06 +0800 [thread overview]
Message-ID: <921fd8fa-48ba-47ca-9330-fccf7c76a80a@linux.dev> (raw)
In-Reply-To: <DHCSILUEKVYC.3DNKLNI6RBENX@garyguo.net>
On 3/26/26 22:40, Gary Guo wrote:
> On Thu Mar 26, 2026 at 6:52 AM GMT, Alvin Sun wrote:
>> Fixes clippy warning:
>> warning: all variants have the same postfix: `Init`
>> --> rust/kernel/sync/set_once.rs:68:1
> I am not sure that this makes the code look nicer :/
>
> AlreadyInit is very clear on what's wrong, which `InitError::Already` is weird.
>
> Perhaps just allow this warning.
Got it, that makes more sense. I was actually a bit confused by this clippy
warning when I first saw it too, wasn't sure whether to just follow it
or not.
Now I know what to do - I'll drop this patch and allow the warning directly.
Best regards,
Alvin
>
> Best,
> Gary
>
>> Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
>> ---
>> rust/kernel/sync/set_once.rs | 18 +++++++++---------
>> 1 file changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/rust/kernel/sync/set_once.rs b/rust/kernel/sync/set_once.rs
>> index db9c5423fade3..3af5538aae1d4 100644
>> --- a/rust/kernel/sync/set_once.rs
>> +++ b/rust/kernel/sync/set_once.rs
>> @@ -67,17 +67,17 @@ fn default() -> Self {
>> #[derive(Debug)]
>> pub enum InitError<E> {
>> /// The `Once` has already been initialized.
>> - AlreadyInit,
>> + Already,
>> /// The `Once` is being raced to initialize by another thread.
>> - RacedInit,
>> + Raced,
>> /// Error occurs during initialization.
>> - DuringInit(E),
>> + Inner(E),
>> }
>>
>> impl<E> From<E> for InitError<E> {
>> #[inline]
>> fn from(err: E) -> Self {
>> - InitError::DuringInit(err)
>> + InitError::Inner(err)
>> }
>> }
>>
>> @@ -85,9 +85,9 @@ impl<E: Into<Error>> From<InitError<E>> for Error {
>> #[inline]
>> fn from(this: InitError<E>) -> Self {
>> match this {
>> - InitError::AlreadyInit => EEXIST,
>> - InitError::RacedInit => EBUSY,
>> - InitError::DuringInit(e) => e.into(),
>> + InitError::Already => EEXIST,
>> + InitError::Raced => EBUSY,
>> + InitError::Inner(e) => e.into(),
>> }
>> }
>> }
>> @@ -155,8 +155,8 @@ pub fn init<E>(&self, init: impl Init<T, E>) -> Result<&T, InitError<E>> {
>> }
>> }
>> }
>> - Err(1) => Err(InitError::RacedInit),
>> - Err(_) => Err(InitError::AlreadyInit),
>> + Err(1) => Err(InitError::Raced),
>> + Err(_) => Err(InitError::Already),
>> }
>> }
>>
next prev parent reply other threads:[~2026-03-27 6:07 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 6:52 [PATCH 00/13] drm/tyr: add debugfs support Alvin Sun
2026-03-26 6:52 ` [PATCH 01/13] rust: sync: support [pin_]init for `SetOnce` Alvin Sun
2026-03-26 6:52 ` [PATCH 02/13] rust: revocable: add lazily instantiated revocable variant Alvin Sun
2026-03-26 6:52 ` [PATCH 03/13] rust: sync: set_once: Rename InitError variants to fix clippy warning Alvin Sun
2026-03-26 14:40 ` Gary Guo
2026-03-27 6:07 ` Alvin Sun [this message]
2026-03-26 16:35 ` Miguel Ojeda
2026-03-27 6:13 ` Alvin Sun
2026-03-26 6:52 ` [PATCH 04/13] rust: sync: add hazard pointer abstraction Alvin Sun
2026-03-26 6:52 ` [PATCH 05/13] rust: revocable: add HazPtrRevocable Alvin Sun
2026-03-26 6:52 ` [PATCH 06/13] rust: revocable: make LazyRevocable use HazPtrRevocable Alvin Sun
2026-03-26 6:53 ` [PATCH 07/13] rust: drm: add Device::primary_index() Alvin Sun
2026-03-26 6:53 ` [PATCH 08/13] rust: drm/gem: add GEM object query helpers for debugfs Alvin Sun
2026-03-26 6:53 ` [PATCH 09/13] rust: drm/gem/shmem: add resident_size() and madv() " Alvin Sun
2026-03-26 6:53 ` [PATCH 10/13] drm/tyr: expose Vm gpuvm_core, gpuvm and va_range as pub(crate) Alvin Sun
2026-03-26 6:53 ` [PATCH 11/13] drm/tyr: add debugfs infrastructure Alvin Sun
2026-03-26 6:53 ` [PATCH 12/13] drm/tyr: add vms and gpuvas debugfs interface Alvin Sun
2026-03-26 6:53 ` [PATCH 13/13] drm/tyr: add gems field and gems " Alvin Sun
2026-03-26 14:32 ` [PATCH 00/13] drm/tyr: add debugfs support Boqun Feng
2026-03-27 6:18 ` Alvin Sun
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=921fd8fa-48ba-47ca-9330-fccf7c76a80a@linux.dev \
--to=alvin.sun@linux.dev \
--cc=a.hindborg@kernel.org \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=sumit.semwal@linaro.org \
--cc=tmgross@umich.edu \
/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