From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3B0419DF49; Thu, 6 Mar 2025 10:14:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741256056; cv=none; b=rL31/x2+EpLLXpt1L2cSPBGmO9MiLrbMlrjKwTVPIgcKZHSI5+Xt4sX+HrKxt4SY8vQlMnNfmlu+Y419hDb/d/Uc+e/cqrtpe9zZM3YpQi8R/T9cVKSY5+Zv9AK1CLYxG/nWF7K1+7xGe0kK300BN8LazuTtNNc1jbKjBQi12MA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741256056; c=relaxed/simple; bh=Ji84DnUxZPaZjWugH0NqsXEiI73Lt2LMDG3qx2jTb9o=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xdgc/sX+AVNlosUD+tfOpgYutc3v1CC0wepWUeR+1JD9++d5XheaUlgmwaIjYMOpt6H+VZpn/gHPTiBKHw2CtgSENShcvhaoKIn6w795kf2sbhhW0lF30wiJfwIfWhP7eX3zdDpJAZf2k/bxwSI0+KEzvvg0qpGr4skQay1U9+E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=SB6szdr7; arc=none smtp.client-ip=185.70.43.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="SB6szdr7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1741256052; x=1741515252; bh=Ji84DnUxZPaZjWugH0NqsXEiI73Lt2LMDG3qx2jTb9o=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=SB6szdr7Gp6dUs8hgrPjccFk3qFPln2m29hwmDy4SPD1aYSGtxaEQVy0H50uYX9Im omEMsdu+iJL3sovHiPicLlaZEMJotcFs2amy7X2aRPf5hcz1Mbt+XxzuqSZe3XH1yt qFLuRmaZErzuK6HH/6S267rJioKx91DwNV3UgDkD4B1eKuDYfn5Bc1Rxfq64BEK++V qN33UFkeBXIuw4O0dWiaHAZqdiWOqTmDFiQzcvZGIgocGpkSZkPV7Qr0Y/tvSRbAUi sJ706qktR/buQoe/h67z6Xc/E7080XFHyWx5Pax3hUlgkWilu5QcRt3tqkluvqo9mt Gb+FhqiAnxwAg== Date: Thu, 06 Mar 2025 10:14:05 +0000 To: Alice Ryhl From: Oliver Mangold Cc: Andreas Hindborg , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Trevor Gross , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] rust: adding UniqueRefCounted and UniqueRef types Message-ID: In-Reply-To: References: <20250305-unique-ref-v4-1-a8fdef7b1c2c@pm.me> <87ldtj8p2m.fsf@kernel.org> <875xkn8k5z.fsf@kernel.org> Feedback-ID: 31808448:user:proton X-Pm-Message-ID: e40e2afc114c2974bd3c93371cd758f2bc37229b Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 250306 0935, Alice Ryhl wrote: >=20 > Ultimately, if a struct implements AlwaysRefcounted, then you can always > increments its refcount. > If you want a version of the struct where that > is not the case, then you need a different struct that does *not* > implement AlwaysRefcounted. > I guess so, but it would be possible to make 'From<&T> for ARef' opt-in, by requiring a separate marker trait. That you can call 'AlwaysRefCounted::inc_ref()' directly doesn't seem a problem to me, as it will only leak the object, not create a reference. A quick grep shows me that there are currently 7 implementers: unsafe impl AlwaysRefCounted for Credential { unsafe impl AlwaysRefCounted for File { unsafe impl AlwaysRefCounted for LocalFile { unsafe impl AlwaysRefCounted for Request { unsafe impl crate::types::AlwaysRefCounted for Device { unsafe impl crate::types::AlwaysRefCounted for Task { unsafe impl AlwaysRefCounted for PidNamespace { So it looks doable to me. Oliver