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

Miguel Ojeda
2024-12-08T21:28:49Z

On Sun, Dec 8, 2024 at 8:40 PM jos <dev.json2@gmail.com> wrote:
>
> How I understand the issue arises when the result of `Lock::try_lock` is called and its return value can be ignored, the lock is never acquired, and no guard is created.

I may be misunderstanding what you are trying to say, but the guard is
created, and the lock is acquired.

So the issue is that someone does not keep the guard around, so the
guard is dropped right away and so the critical section is empty.

Cheers,
Miguel