Re: [PATCH v3] rust: sync: make AlwaysRefCounted::inc_ref an associated function
From: Nicolás Antinori
Date: Thu Nov 26 2026 - 08:48:36 EST
On Thu Nov 26, 2026 at 7:43 AM -03, Tran Van Tien wrote:
> In-Reply-To: <1795684556.6d661f19@xxxxxxxxx>
> References: <1795684556.6d661f19@xxxxxxxxx>
>
> Incrementing a reference count must be a deliberate act, and every
> inc_ref must be matched by exactly one dec_ref. Making inc_ref an
> associated function that takes a NonNull<Self> mirrors dec_ref, which
> is already an associated function because the object is freed when the
> count reaches zero.
>
> Having one half of the protocol take a reference and the other half a
> raw pointer makes the pairing harder to review and easier to get wrong.
>
> This was suggested by Benno Lossin.
>
> Suggested-by: Benno Lossin <lossin@xxxxxxxxxx>
> Link: https://github.com/Rust-for-Linux/linux/issues/1177
> Signed-off-by: Tran Van Tien <7enlab@xxxxxxxxx>
> --
Hello! There is a patch that implement this [1] with some 'Reviewed-by:'
tags.
The last patch is from June, maybe it can be coordinated with Trevor
Chan or you to take it over if it needs some updates.
Regards
[1] https://lore.kernel.org/rust-for-linux/20260628100731.64885-1-trev@xxxxxxxxxxxx/