From: "Gary Guo" <gary@garyguo.net>
To: "Ashutosh Desai" <ashutoshdesai993@gmail.com>, <ojeda@kernel.org>
Cc: <peterz@infradead.org>, <mingo@redhat.com>, <will@kernel.org>,
<boqun@kernel.org>, <wl@lyx.org>, <gary@garyguo.net>,
<bjorn3_gh@protonmail.com>, <lossin@kernel.org>,
<a.hindborg@kernel.org>, <aliceryhl@google.com>,
<tmgross@umich.edu>, <dakr@kernel.org>,
<linux-kernel@vger.kernel.org>, <rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH v2] rust: sync: add #[must_use] to GlobalGuard and GlobalLock::try_lock
Date: Tue, 05 May 2026 13:38:07 +0100 [thread overview]
Message-ID: <DIAQYXAWDBCM.8GYR67E1I13P@garyguo.net> (raw)
In-Reply-To: <20260502160057.3402896-1-ashutoshdesai993@gmail.com>
On Sat May 2, 2026 at 5:00 PM BST, Ashutosh Desai wrote:
> Guard is marked #[must_use] since dropping it releases the lock. GlobalGuard
> wraps Guard with identical semantics but was missing the annotation, so
> discarding it would silently compile without warning.
>
> Similarly, GlobalLock::try_lock was missing #[must_use]. Option<T> does not
> propagate #[must_use] from T, so the attribute needs to be on the function
> directly - same reason Lock::try_lock has it.
>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Ashutosh Desai <ashutoshdesai993@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> Changes in v2:
> - Remove explanatory comment above #[must_use] on try_lock (Alice Ryhl)
>
> Link to v1: https://lore.kernel.org/rust-for-linux/20260419001141.211935-1-ashutoshdesai993@gmail.com/
>
> rust/kernel/sync/lock/global.rs | 2 ++
> 1 file changed, 2 insertions(+)
prev parent reply other threads:[~2026-05-05 12:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-02 16:00 [PATCH v2] rust: sync: add #[must_use] to GlobalGuard and GlobalLock::try_lock Ashutosh Desai
2026-05-05 12:38 ` Gary Guo [this message]
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=DIAQYXAWDBCM.8GYR67E1I13P@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=ashutoshdesai993@gmail.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mingo@redhat.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=will@kernel.org \
--cc=wl@lyx.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