Re: [PATCH v5] rust: add global lock support

From: Alice Ryhl
Date: Tue Oct 22 2024 - 07:04:52 EST


On Mon, Oct 21, 2024 at 3:18 PM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
> + /// Lock this global lock.
> + pub fn lock(&'static self) -> GuardTyp {
> + $crate::global_lock_inner!(new_guard $($guard)? {
> + self.inner.lock()
> + })
> + }
> +
> + /// Lock this global lock.
> + #[allow(clippy::needless_question_mark)]
> + pub fn try_lock(&'static self) -> Option<GuardTyp> {
> + Some($crate::global_lock_inner!(new_guard $($guard)? {
> + self.inner.try_lock()?
> + }))
> + }

It came up during the meeting that these should just be pub, but now I
remember why I didn't do that. Making them pub means that you now get
"private type `MyCustomstruct` in public interface" errors on
whichever custom struct you're using as the item type of the lock.

And this error isn't a lint you can silence!

Alice