Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp302907rdb; Thu, 8 Feb 2024 06:31:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUn//Bvx7Nn4mwc+b21iPT42cNA98wMMmReGB0b1L1XHMneOjHaEkaYvDK9EGQU+qOklvQ0vF5uIS2zcoeQUtjbX0g1tTor/P0CKOJb2Q== X-Google-Smtp-Source: AGHT+IHJDv0Vjtruxq7ljSYvAZXilGe0NhgdgtXADlvtkICsMLqmvwFDe1stFir3zaq6CLEeSW93 X-Received: by 2002:a17:906:1451:b0:a38:4aa:f61b with SMTP id q17-20020a170906145100b00a3804aaf61bmr6274991ejc.36.1707402707731; Thu, 08 Feb 2024 06:31:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707402707; cv=pass; d=google.com; s=arc-20160816; b=fkxoIxw/Jdwf6eMMTEmOSjmcLRoeBYXRv1c6G1GIqWvQJ63eTn5qpF+Gv5qoh14rvc uOv0C9mwhMXQyXap+7DQ62JKSdW79wi2PpRAPLDti5FQHI6XB4KQzGWWUwwEc3vX9teI uD0HsT+e61KF2UIr0dW0OFryL3uPiTcAIXaU8GixyXS5VJmefxaDfGxrXeeQsYYGWnjl bFw474J1GpVB9KOQgU6S/4XjYYeeiNJsKPcU5T6+L0kdNtGiQ5mdYYdcGLuP0g4r0VC3 pl6eGOHclKqhfTpo4T/16uStyMn16XaOUsu74vFiA/BU9Kaab2PNiYXRdx5/eyxL/xVn lJpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=obCGu9I28pwHjWZdV5bvQfg8AiUFYhtKduRS4S8NEto=; fh=IpSk8BspPdpqU0QkPDGmsl5Fjy8tBO1yDwvYCxpCz9I=; b=wbKhvuJ6qCumb8/lK9MQhIDG7LAaxHEM4uW2/qS/t2altHoHTU6peTXFrRLjGVWNpk 5il8zjt9a6n13BqmPXf35zoM1nX6kbl/yQpxJoiAE/EBPopvbwqKNx+z3/Z6VH36d5wq O4c2fxBWvh9JFnw5oY55yvbo+7sHCrhAsNabb50tSUdr+nHUobkva25E2IyUtsxJjaHO bJ+uo+WPVd8XYQOt0uBshIRIzqncuPnHPYWPZ0hVzWT5ie1CmaRVlO4EDLfTo05fJecd OjSDWG3Y7qUaXz7xOMIZ4NuOZUKlBLTCqhRQY8jpt8TutTqr4p8Gczy18eKbzTP+DNy8 tjgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1XKhDKP3; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-58232-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58232-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCU0CbrrDE5tHoY7AwvutxSek/5DLbVbcK8G34fdtyjjcNJAotdNlHPd14MAPlb/a6PRTKWg1tiF7Ao/4YxXQofDnnu/ERc65y10GSXV1A== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s27-20020a170906169b00b00a3ba261d09dsi90363ejd.709.2024.02.08.06.31.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 06:31:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58232-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1XKhDKP3; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-58232-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58232-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id B42B31F28694 for ; Thu, 8 Feb 2024 14:31:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B56F5200D2; Thu, 8 Feb 2024 14:31:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="1XKhDKP3" Received: from mail-vk1-f174.google.com (mail-vk1-f174.google.com [209.85.221.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 707E1535AC for ; Thu, 8 Feb 2024 14:31:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707402689; cv=none; b=Xxl98SZzJcA3bluHWLqgI3qMKAnlykZEVJZpohLrE0lBIFHkjWlBT+TPWA/Zo69wyX7rA/rJvlwYdehTG9CvpztDWZ6yWkOtoXiiuKycaMAY1bTz81ASRSr2NTpBXmQihjJ7t8QbobOqDgxpt0NFLbkZRlxN6jdxw01mlrLMDyg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707402689; c=relaxed/simple; bh=2X7cnvNc0POJtDhx64/0CYoKnC/Qcp2jn+JvTMeuE+s=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=HdccdfTdWMA63zXwC1xVbriynru6IMkHcI+qISlV5MqM8LAQ7SYGoG0yxP0mWfgeIpWdsMT31PeDewl+Paud2BW8FT7FZQhSjeMUhgvxwIaKt08iCJDT0rgq+AVimPDOR4W2UKTvTLeZKR45yopstVEmmnKmyMrDeAc9HW8X3dk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=1XKhDKP3; arc=none smtp.client-ip=209.85.221.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-vk1-f174.google.com with SMTP id 71dfb90a1353d-4c01ca67504so703795e0c.2 for ; Thu, 08 Feb 2024 06:31:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707402687; x=1708007487; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=obCGu9I28pwHjWZdV5bvQfg8AiUFYhtKduRS4S8NEto=; b=1XKhDKP3IDjwHsUUKmSoBX+cNQVWjyaZ0P8cQW6tTqteF6VGhvugcLwVNZPszUBN0k YuNQ99tH6NmPqjg2u3aMgqR2XHeaPKNhCG9ZGd+NHWFSChDY9I4x1J5EF1ihTlwWPUoo xwRW/yNPHzHcr4g/ImgLbuc5H0fkbI+iwSZfwVESRks2/agT/wKEgK4y++IC3fgUHrAd /uWrHfDpa45P5s09c4Vxc5dWtJplo+cOa1lefH6e4Ib9s+8joxY8VrbTRw+cI4nkLc3U 5FdreHwwL7cTy8ZJnAUXVcUPkV5chnio1UacUHH+Y3PKMppXdGj3TiAhl1LicjZK41Ex eIsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707402687; x=1708007487; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=obCGu9I28pwHjWZdV5bvQfg8AiUFYhtKduRS4S8NEto=; b=ksgpLto9OImbhyBcOpUf4rjzPuw6UE2bTxGwXOk9sXavAi/K+ciF2JNsqKhAaIiCFS Ll/nK93T4+md9G4r6oXN2daEQue6+X9/WURYB6lC5kUOrVYoD7CMUQE786lhOTqQhzKE iq5RKm0GiSJBwLchn8YDGHjkDvI7kJpDMYQ7XxMbp+w8FCxYlkCpprTnzIJWuvE8x1NT Mjea07ZXUGl1hpjc06QSdp88lhVjYBygeqlIjo3ixM7DTVJASR6+slBNOhDkqkR36tvB +Asq4nJmWy9Qs/UuBGK6DDJXVET/DYA6XF0fziFeNpdb79DSqgoHE423WbWxQzKQ5SJt tkLw== X-Forwarded-Encrypted: i=1; AJvYcCXuAwZNXioXcHPuuBjdpKZcOUy9Sob5j55UN364I5RkWqKAKZ5TLCkG90M3rlZkLot5xLE09MV5FzZsFQN9TQPELmuqPgn1ylPS6Atr X-Gm-Message-State: AOJu0Yw1gaCkY1VZ4niMnMrZEP0l9PmOv36Zkz9it+yAiN9zYagI+IBe dUQLGwKIb94JmebKMsEQ12P68Yve0yTTXnPls/YEK/J/mrtufop1Qzrx5cIbccC+YCKWAww4Cg/ TDtMb3P4W8p4dEypnSm4lJnwkkU/lB0P/WHHw X-Received: by 2002:a05:6122:c97:b0:4c0:237a:3842 with SMTP id ba23-20020a0561220c9700b004c0237a3842mr6366031vkb.10.1707402687081; Thu, 08 Feb 2024 06:31:27 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240205091842.2858516-1-aliceryhl@google.com> In-Reply-To: From: Alice Ryhl Date: Thu, 8 Feb 2024 15:31:15 +0100 Message-ID: Subject: Re: [PATCH] rust: stop using ptr_metadata feature To: Trevor Gross Cc: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Feb 5, 2024 at 10:02=E2=80=AFPM Trevor Gross wr= ote: > > On Mon, Feb 5, 2024 at 3:19=E2=80=AFAM Alice Ryhl = wrote: > > // SAFETY: The metadata of `T` and `ArcInner` is the same b= ecause `ArcInner` is a struct > > // with `T` as its last field. > > // > > // This is documented at: > > // . > > The comment should be reworded, no more metadata and no unsafe block > so it doesn't have to be SAFETY. How about this? // Pointer casts leave the metadata unchanged. This is okay because the metadata of `T` and // `ArcInner` is the same since `ArcInner` is a struct with `T` as its last field. // // This is documented at: // . > > - let metadata: as Pointee>::Metadata =3D > > - unsafe { core::mem::transmute_copy(&metadata) }; > > + let ptr =3D ptr as *mut ArcInner; > > Nit: this could be `.cast::>().cast_mut()` to make the > intentional mutability change clear. The `.cast()` method can't be used here. It only works for sized types. Alice