From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-24418.protonmail.ch (mail-24418.protonmail.ch [109.224.244.18]) (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 53BDD383A5; Wed, 26 Mar 2025 22:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.224.244.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743027355; cv=none; b=BuYFO3syV0PrjBe0cW8mMSfkdRUR5JRUERlRbTd3hQ/KLnRSsJ+n+gRwnEx4Gm77eGsBxxXBTMP+dh3Jw027sGf8pprbQDzeGylgICIN6cwIQytXVR5IOLL6dxFZwkKSq8r9zWyuqskrDIipl5KD2eq4H97Z8X9ppN2r8oVe8Nw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743027355; c=relaxed/simple; bh=to6Tsfx7WaJmCqvucS0jsS/ayq4WMOWhnETk19VRfdE=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CMju6WGh3tNRhQ0d+wLxGgo0yrSj0C2S+oitt4+2vCdMFjh01iBBGzbpETTqWlhu6ScW2l5803psizo95gmQGYBx4rjbU1GQWK2FHF38OTOcbPlBcpyMW6D7KcX1dWMGw8q2smGVWmit0v+5ToMr/ZqTe3b0dLIEp74W82aPeXg= 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=NfmhZFGn; arc=none smtp.client-ip=109.224.244.18 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="NfmhZFGn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1743027350; x=1743286550; bh=9oUH4nV7QWQ54U20IxphlyDvPRuA4nnGHt2VBGcRbbw=; 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=NfmhZFGnZRbbdqlbfPwEKd/ANRL+wlFC9YDrN0Ocytq9tNKX28ozucbnFQZO06h4A 6bp4EJwQEGWQs+vJ20ZYU/ylXbKQXav5uZljiSFbf2HJzHtVxY3KH7BZ6KaO4v9GG6 ODNyZAT49Y1XeMXKHT7KvLLy2J9CkWVhB3HsD+ZUrWuZR0PUeh9vsHjiUNkKhcA8e2 G+aKEPyabTNhQmVRkg9pLTTTgls9QAfZ2qsAMu+RlEDatw+wGMe4oevr5frzJgWhwI RMzWu7EteG8oYB3njlaRNRwAPsZ6DT+m5ybUsoU2gdPSloc2RgOkZSRju2yiIvP6qL HGLYeu1DORYJQ== Date: Wed, 26 Mar 2025 22:15:43 +0000 To: Tamir Duberstein From: Benno Lossin Cc: Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Brendan Higgins , David Gow , Rae Moar , Bjorn Helgaas , Luis Chamberlain , Russ Weight , Rob Herring , Saravana Kannan , Abdiel Janulgue , Daniel Almeida , Robin Murphy , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , FUJITA Tomonori , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-pci@vger.kernel.org, linux-block@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, netdev@vger.kernel.org Subject: Re: [PATCH v7 7/7] rust: enable `clippy::ref_as_ptr` lint Message-ID: In-Reply-To: References: <20250325-ptr-as-ptr-v7-0-87ab452147b9@gmail.com> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 9b3e0eaf59f5bd85b3b1266b193b59b5e33ec08b 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 Wed Mar 26, 2025 at 11:09 PM CET, Tamir Duberstein wrote: > On Wed, Mar 26, 2025 at 5:09=E2=80=AFPM Benno Lossin wrote: >> On Wed Mar 26, 2025 at 8:06 PM CET, Tamir Duberstein wrote: >> > On Wed, Mar 26, 2025 at 1:36=E2=80=AFPM Benno Lossin wrote: >> >> On Wed Mar 26, 2025 at 5:57 PM CET, Tamir Duberstein wrote: >> >> > >> >> > Yeah, we should do this - but again: not relevant in this discussio= n. >> >> >> >> I think it's pretty relevant. >> > >> > It's not relevant because we're no longer talking about transmuting >> > pointer to pointer. The two options are: >> > 1. transmute reference to reference. >> > 2. coerce reference to pointer, `as` cast pointer to pointer (triggers >> > `ptr_as_ptr`), reborrow pointer to reference. >> > >> > If anyone can help me understand why (2) is better than (1), I'd >> > certainly appreciate it. >> >> I am very confident that (2) is correct. With (1) I'm not sure (see >> above), so that's why I mentioned it. > > Can you help me understand why you're confident about (2) but not (1)? My explanation from above explains why I'm not confident about (1): For ptr-to-int transmutes, I know that they will probably remove provenance, hence I am a bit cautious about using them for ptr-to-ptr o= r ref-to-ref. The reason I'm confident about (2) is that that is the canonical way to cast the type of a reference pointing to an `!Sized` value. --- Cheers, Benno