Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1952100lqz; Tue, 2 Apr 2024 02:46:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXqP2gYnoJVyYIiWd6kUNo3Yolv0UvwoqHglLa0UB9oBZp1/8xCDmL8OC7iMmK/twbSy/zYqSiyrwjGu3JvYdpWSVrV9JE5ral5rUBAlw== X-Google-Smtp-Source: AGHT+IEFtITiVT1tJIUGo3C8HPJPiwf+ASAS/49cGkFyMp9fhG7c7RKQ5s0GV0xBHV99k5DSlRG4 X-Received: by 2002:a50:a6d7:0:b0:56d:eef3:31af with SMTP id f23-20020a50a6d7000000b0056deef331afmr455722edc.38.1712051194498; Tue, 02 Apr 2024 02:46:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712051194; cv=pass; d=google.com; s=arc-20160816; b=c8yR8a0REmL0gvjcCekkC/dOjMl/gLA96yzpJugHKfrX1ceG7tLGCVUbgy/qAgv5WD hA8Ggc+AgIo+pv3fqHpdy1DWN1TimaXnLRN7NDVn8TF1/zKNLOQqN0mc0dLAF3qU5Ewb zbmcnNEhaf3Akfn8hpPtz3ZGYkX31c8sjQDrecS8loV7VRTrM1M+I7FpFh7HSm45LY6l rduB28Z8SF1FVoP4kK+N3YPcQzZTltle3qpWADD8MwyBCMhZlGW1DbL320z87zAHnOB/ KOqdG3TNrJ+IwgkZsLf2cQWsJ3wvXzDBiXdS6s65v8cFZ/5c55nvPSedLX8mnqUuvyJ3 Gaog== 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=B1dO/cGx1ctVP9vVa9nf8DWsXEGQBHZzRz0NgOZhVoY=; fh=G4uNWus578xZoiLI3w4K98+4SeJawZMnvDUKjF+aOgM=; b=D4/6sFhZDSN8pGdWk1IxyQE34Mhu/eYyB/N2Alx4PeY5PaZVcHtPqcae9u8x6KcXU0 dBQyvTmSkREsJEtxouRaKbqtYfCVner8F8v7ACebBbZZRwFFiyaRBizwNln6Mbxb0vmv /T6Le483V2x+/Cuw2lo83Tq5dzK7SQwRhas3gMmShZZdLr/0iERjFgEKgxt8Tr8Ob4Uj VHjDxb9xmP59bXAhKTRNSqnzn0lnyvS2ebgANfN+4JPs9XWMvBUgKVo02i+sSpjmpg3T Yj0jjJ9Kc8Xhx6MJvDs3Ky2XdPGpyJc8gofCVMIfs3EpT6UyfWwFWmeya84SmRO5NL/3 O6MA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hooYKUIx; 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-127654-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127654-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m5-20020a056402430500b0056c5a43db91si4973849edc.477.2024.04.02.02.46.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 02:46:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127654-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=hooYKUIx; 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-127654-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127654-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 3D5E91F22EF7 for ; Tue, 2 Apr 2024 09:46:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB64358211; Tue, 2 Apr 2024 09:46:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hooYKUIx" Received: from mail-vs1-f51.google.com (mail-vs1-f51.google.com [209.85.217.51]) (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 745CD58203 for ; Tue, 2 Apr 2024 09:46:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712051184; cv=none; b=HZYa3Zf4D3w/Unw8hGhn/TRs5fUcvJybIkxlCkll9FOvnznTLvqBDMlijtMFzt48v1UXWu51Y++WR7IA3xOeVLnlECYC6FPSavqgk6t5wWHfNCWuBA9JSI/UxVJ8weZr25c4VNqHJrO7qBIcHVVho4JmQQ4hUEO4N/m7pkuu3ZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712051184; c=relaxed/simple; bh=XggWFGhtT/fWL1kIWx1OwviwIwPRpAp9kiwk6uVXE38=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=lf39t3fHGM7E2huG1Wez4ItW5uxIPRxzMiKhkRAYQpnJND2AAXUe9D7ueBQhHFgqp+5CQu98ATTwp5C0HShn59M6k7/2dTXxYhpBIZ05v72psbyUj0KW+xZqnAKcDLpa/iOXS/7EagZvD172YYMyJZTBxf+8q+f9BPXI+9uJBmo= 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=hooYKUIx; arc=none smtp.client-ip=209.85.217.51 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-vs1-f51.google.com with SMTP id ada2fe7eead31-4783964353dso1688676137.2 for ; Tue, 02 Apr 2024 02:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712051182; x=1712655982; 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=B1dO/cGx1ctVP9vVa9nf8DWsXEGQBHZzRz0NgOZhVoY=; b=hooYKUIx8HvBO2a+hT4X9jMCnm2liwwG0r+yh4zNemt26nFD9GHjG2nfNymuAWnGUZ mfAJ0+PXLc7lL4M1t1LZUKC8/dlTlrJja4b9swyy6rnqHtl3N8aKlF7BbQNXnPVtM1oE CfGn8PeVJgHLOSJrE/K2SqgEsnUC1JuzMxqibWPxBP0ynkMwH9doplxrtXQ3mNTaXFJt RkvoPkK3c74tP2T+PO78/fNd1cXIAim49kh6F/zZgvDuOb/EtzE0bTjNNNHaNbvK3ibm PzU+TXOoUOe4eSbxXBIOFpJ7jzil0FYTljsLoedzXMnbGzhb3LEM2vXOjHb+TVLd/qUr CTBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712051182; x=1712655982; 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=B1dO/cGx1ctVP9vVa9nf8DWsXEGQBHZzRz0NgOZhVoY=; b=OUfUCOR3PN0OyJqcWCqWkf1tTaw5QVtI7TNEyIAI2N3t37eybFexc2gUoYGpMmtpwG oR4qD9iIRl6jvfxjE2JFJSiMWOVSeqpBszcgEcC5UZMnPXIatk5VBNpCXQsEOIqz+mH/ ux7wwYaPXy4I6HEPSaEEXPKS7ik9QYeTlwwseZv2IZ/rgv14SNwT/b1JEcGewNVxEi68 niqv1dw9XLtVcGGRO2QoSxa66L1OC/oNAt8WQytvAnPYyOMGrq/nKotAUl1mt5jC/b8D wAX9UcrQLElU5xrUXN7bY/h+eVaVucXeXanHgAaT3H3zkeXJxY2GLUivtgx0+yioZW9H 9OlQ== X-Forwarded-Encrypted: i=1; AJvYcCUBOpK4Z9E05Wd7NlRG2HYTO4epW0FqLnJee73r9uorHZ3V83GohjbtQUnNnKf68C4XgWwAvKS2VE2QbsDwzxlL61JRxlDwrHk+czZM X-Gm-Message-State: AOJu0YznD8JzOt6g9+YOvysc+ctK4/UUg95PC04yWRLP9KasEuFBOOhN cv6CCadV7ZhDFMx5eAP9zc3+Op01ub7VwCrq8S5NHbBSauQWuFfUseGpNXFjSygWaCPXFECp7sU UQBN0MTpRNj8qFP0SjZpZQdJ+2adzMbGmUbYz X-Received: by 2002:a67:f8c9:0:b0:476:d833:ef6d with SMTP id c9-20020a67f8c9000000b00476d833ef6dmr9524383vsp.19.1712051182365; Tue, 02 Apr 2024 02:46:22 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240401214543.1242286-1-boqun.feng@gmail.com> In-Reply-To: <20240401214543.1242286-1-boqun.feng@gmail.com> From: Alice Ryhl Date: Tue, 2 Apr 2024 11:46:11 +0200 Message-ID: Subject: Re: [PATCH] rust: types: Make Opaque::get const To: Boqun Feng Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Martin Rodriguez Reboredo , Obei Sideg Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 1, 2024 at 11:46=E2=80=AFPM Boqun Feng w= rote: > > To support a potential usage: > > static foo: Opaque =3D ..; // Or defined in an extern block. > > ... > > fn bar() { > let ptr =3D foo.get(); > } > > `Opaque::get` need to be `const`, otherwise compiler will complain > because calls on statics are limited to const functions. > > Also `Opaque::get` should be naturally `const` since it's a composition > of two `const` functions: `UnsafeCell::get` and `ptr::cast`. > > Signed-off-by: Boqun Feng Reviewed-by: Alice Ryhl