Re: [PATCH v2] rust: sync: add #[must_use] to GlobalGuard and GlobalLock::try_lock
From: Boqun Feng
Date: Thu Jun 04 2026 - 15:35:35 EST
On Thu, Jun 4, 2026, at 11:44 AM, Miguel Ojeda wrote:
> On Sat, May 2, 2026 at 6:02 PM Ashutosh Desai
> <ashutoshdesai993@xxxxxxxxx> 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@xxxxxxxxxx>
>> Signed-off-by: Ashutosh Desai <ashutoshdesai993@xxxxxxxxx>
>
> I could pick this one -- do you want me to, Boqun?
>
Yes, please! Thank you!
Regards,
Boqun
> Cheers,
> Miguel