Re: [PATCH v6] rust: sync: add #[must_use] to Lock::try_lock

Boqun Feng
2025-01-15T18:12:54Z

On Thu, Jan 09, 2025 at 02:05:41PM +0100, Alice Ryhl wrote:
> On Thu, Dec 12, 2024 at 4:48 PM Jason Devers <dev.json2@gmail.com> wrote:
> >
> > The `Lock::try_lock` function returns an `Option<Guard<...>>`, but it
> > currently does not issue a warning if the return value is unused.
> > To avoid potential bugs, the `#[must_use]` annotation is added to ensure proper usage.
> >
> > Note that `T` is `#[must_use]` but `Option<T>` is not.
> > For more context, see: https://github.com/rust-lang/rust/issues/71368.
> >
> > Suggested-by: Alice Ryhl <aliceryhl@google.com>
> > Link: https://github.com/Rust-for-Linux/linux/issues/1133
> > Signed-off-by: Jason Devers <dev.json2@gmail.com>
>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>

Queued. I reworded a bit on the commit log because of the tip maintainer
guideline. Thank you both!

Regards,
Boqun