Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp32884lqp; Thu, 4 Apr 2024 06:29:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1+9tbvT6Wv5cE3UGMdGI1QEE3bexkIxhOuhZ2/xNNAUK6dVNARwP4BtUPK05MbYYTBadsd1ctx6LJPNgJgoBw4lMVbFQpiX86oCbXqw== X-Google-Smtp-Source: AGHT+IGZK9o/IC5T4mvvrXQMWAMLDGoGMnfz+ncheDdEh8ZApu2B9jeH2bggYntXlbApJbq0BMSJ X-Received: by 2002:a05:6a20:8f07:b0:1a7:240a:ee64 with SMTP id b7-20020a056a208f0700b001a7240aee64mr3113370pzk.38.1712237394233; Thu, 04 Apr 2024 06:29:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712237394; cv=pass; d=google.com; s=arc-20160816; b=yWOzkfvY84xRnhHK126KnXgbFSQzgJhhWJnPBgTXkHsNqoiMNsLApzpBdyn3L633G6 802luv5Sov6VRT0ZP3Ntm9oW5/kijnR/l5RE5vk/fcWGsHRU1PR5iCHu2W7nbJIYuMhD NmaJCrkUKvyyAjfqxb+GLJLANW2NcSZuopT54d0a3qPS3YRvgmAjhUefmv/X8QFqED9Z E3e89OziXj32Dfb02r2wiRNGfg9x3exjqK7oUvYyeDBOQ+jEe2N4CQMYX5EZyh6eEWrv fmjW4AzhRbGmqHiqhJGl8C1lXlVxhb46Aq6Os3TLcyx5YJvoSU12x37pqOyBsHJgL83x RdZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:feedback-id:references :in-reply-to:message-id:subject:cc:from:to:date:dkim-signature; bh=oeSJBTz+vnlmc3oPqtdJLsV9ot2/7tEkK8xNb1dVcUY=; fh=NVLHYNxTFxZg90CuAUl5EFs9nACqSf1JvKaCbeMsn7U=; b=yd6n8IvjOHU1HUJPC5FjF7WWfaoIpiz56O7me4RpuXLZsyrcgLOAxDNBGzbZo51PWp giM/56X/oV4VNyRRFhOoGUEq6K/UHLQRHMudWrP8gqhL2DCffWc5O4ZEF5rBsk3PRKBR FCoCw8uSA7IEjQcE0G1KbpY+FZXJvTAKRH3Ef7NvsZ5jJhvSc6y/mncgIz+bwREaJttS 7zpKUCxB+ZoLFU7BimaW7UIXnibyUlVstcbljrUaweK+11hWIOcSYjsT+sLZ7U4aN2GH m+qFFSaKiRsgdWUW/H2h9P4RpiEYWdVurXZMbRBabA2rsJeN3oAPz7/fFIQp2HI2q/Cm lRPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=mXGrdLWt; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-131503-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131503-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i3-20020a17090332c300b001e012417887si15639364plr.283.2024.04.04.06.29.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 06:29:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131503-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=mXGrdLWt; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-131503-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131503-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BD6B628F60B for ; Thu, 4 Apr 2024 13:28:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BB10127B51; Thu, 4 Apr 2024 13:28:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="mXGrdLWt" 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 E425F823C3 for ; Thu, 4 Apr 2024 13:28:26 +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=1712237308; cv=none; b=OKJa2m0C9yqOuuQEgw01LuQIhqsul3B1PbdFULY05p8q09NHQb4Cv384bYLUishLB541jnQ3xTfqNpVQ5gIlhsO0vquKShcTB58NShqM89PwAPYKw9XmYoEKdVeSzkSudM+3lJmW8OtoJFu7mbwYo/JmGWUIwgG3HQOAxxdAREU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712237308; c=relaxed/simple; bh=5Dfs/b/6BwRGYkpvYujP65mkScmyquVJPMK3QpaXkPA=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D2yvomNqVPt95I41CYA4rOnY7yqXBRLsD7pnGnIE/vV7RgdBnKLLHY2yzpDagotLavz3Mq2E5cmc+wmmOCHheIqOGYyN6XMwp9pwjiqo4uKGiJUuY9fU/oIrlBEc61NBFTQNuvleFfWlyEy+ZuDRa+07laxjPH+Yve0TP8foNAo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=mXGrdLWt; arc=none smtp.client-ip=185.70.43.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1712237304; x=1712496504; bh=oeSJBTz+vnlmc3oPqtdJLsV9ot2/7tEkK8xNb1dVcUY=; 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; b=mXGrdLWtP3XQq+ln5kCxi4M7EvfUo4H3h8C/v2evQ1e8xlQEmjoZSBDpqsQUQgaHI tYXsXjPevCXwpjqn6fTXzV3p9Yl7UvYCNy80R7Qd12z8Ok4bGKkZs5hwKvzrgqbpKp OdId7LJqf5YS2AeyPJD2KfL95tNw68szKQ8k6M22kHaP4zbi0Pm/krDnkS6EnKu6zi p0PGSyyhr1JcxwPJibxzaPsgY0fabezYQzE+KfxiIIrSYaJjQNP6M1zAL5+ClkZInH SGmuuvfcbby3ZN56R39V5MSLRAaLxgwdR3aZSRvTJeceT0QMZx162OnJbHB8Z+jfmO pWYsCJ+ENrnuQ== Date: Thu, 04 Apr 2024 13:28:16 +0000 To: Alice Ryhl From: Benno Lossin Cc: Miguel Ojeda , Andrew Morton , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Marco Elver , Kees Cook , Coly Li , Paolo Abeni , Pierre Gondois , Ingo Molnar , Jakub Kicinski , Wei Yang , Matthew Wilcox , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Subject: Re: [PATCH 7/9] rust: list: add cursor Message-ID: In-Reply-To: References: <20240402-linked-list-v1-0-b1c59ba7ae3b@google.com> <20240402-linked-list-v1-7-b1c59ba7ae3b@google.com> <4aaf7fd7-49ed-4b3e-b691-0d8d7d426d3a@proton.me> Feedback-ID: 71780778:user:proton Precedence: bulk X-Mailing-List: linux-kernel@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 03.04.24 14:49, Alice Ryhl wrote: > On Wed, Apr 3, 2024 at 2:19=E2=80=AFPM Benno Lossin wrote: >> On 02.04.24 14:17, Alice Ryhl wrote: >>> +impl<'a, T: ?Sized + ListItem, const ID: u64> Cursor<'a, T, ID> { >>> + /// Access the current element of this cursor. >>> + pub fn current(&self) -> ArcBorrow<'_, T> { >>> + // SAFETY: The `current` pointer points a value in the list. >>> + let me =3D unsafe { T::view_value(ListLinks::from_fields(self.= current)) }; >>> + // SAFETY: >>> + // * All values in a list are stored in an `Arc`. >>> + // * The value cannot be removed from the list for the duratio= n of the lifetime annotated >>> + // on the returned `ArcBorrow`, because removing it from the= list would require mutable >>> + // access to the cursor or the list. However, the `ArcBorrow= ` holds an immutable borrow >>> + // on the cursor, which in turn holds an immutable borrow on= the list, so any such >> >> The cursor has a mutable borrow on the list. >> >> >>> + // mutable access requires first releasing the immutable bor= row on the cursor. >>> + // * Values in a list never have a `UniqueArc` reference. >> >> Is there some type invariant guaranteeing this? >=20 > The List owns a ListArc reference to the value. It would be unsound > for there to also be a UniqueArc reference to it. I think it would be good to add the existence of the `ListArc` as an explanation. --=20 Cheers, Benno