Re: [PATCH 2/2] rust: sync: require `Sync` for `Backend::GuardState`
From: Alice Ryhl
Date: Tue Sep 03 2024 - 05:34:45 EST
On Tue, Sep 3, 2024 at 11:17 AM Benno Lossin <benno.lossin@xxxxxxxxx> wrote:
>
> `Guard<T, B>` implements `Sync` when `T` is `Sync`. Since this does not
> depend on `B`, creating a `Guard` that is `Sync`, but with `!Sync` state
> is possible. This is a soundness issue, thus add the bounds to the
> respective impls.
>
> Signed-off-by: Benno Lossin <benno.lossin@xxxxxxxxx>
Right now, a `&Guard<T, B>` has exactly the same powers as &T, as the
only thing you can do on the guard with only a shared reference is
deref to a &T. So the bounds are correct as they are, unless new APIs
are added (which seems unlikely?). But the safety comment could
certainly be improved.
Alice