Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1742659lqz; Mon, 1 Apr 2024 16:22:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsdeiR5LHPT++GhK27Eyu1TDZdFQ8pMq6r9CQ/F3apMF3x7bke3WgzQ5sT3PmOI6HneWdEBijWdjFw6ANrGPxcHNqJBFywL5BRmODuRw== X-Google-Smtp-Source: AGHT+IHdMbzECAWX9+Z/CG7n6g9aD64ThYTwE2fcaDkUWtV65f1fR9DETOX5cvr/ygWioHwsVINM X-Received: by 2002:a05:6a20:2d2a:b0:1a3:bfce:ec9e with SMTP id g42-20020a056a202d2a00b001a3bfceec9emr15351844pzl.18.1712013739793; Mon, 01 Apr 2024 16:22:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712013739; cv=pass; d=google.com; s=arc-20160816; b=BdNyltmVbU2V7E+MCvtxiR1Wmo6TLnKkwQZMh470wIhviC0e/e5jn8Su67hFWlQwNV qByHiQi2gEtlAve0Zz8aS+q4zydgjpQmfK37R73UZXSoE6HM25M0HB+BxJQp1qWnyqns L4CpqW1WfZ8CUUB/snUxiYlYBarJE+CbfQnRCKgmn4yvBXBhYw3LfI/V8Ka7xlSTp1ng 4vhD3RuDtH9CrMwHn86RLOIfMmjMjJdo0Ek0oAHY6x75DMVKxnIUmXqVrZiNcyxkKSiU c1RalMi/bGBUmeVFfKcoPkgTv1VvnFCstyV3z6Om6oTnYkezi9ELrEALs0/SPBRx+d30 lcqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=D1mxLt9IrQqWthikg7YY8D2OyqeJAzfgA0Sf3WwzMsM=; fh=BYfUWCAN++t6qSP1kxDOVuxf9o55Sl3Ru0/jQpa/LUs=; b=TiL6U6xBeL6MbKf11LdLxHu3lnWXM12avfujB+ykzcgfgS+PfGnf8QoGV6aus66y6Y JTtQzV0O9gu9OsTnXmrFTA1xnwyJbtaLC03z/ZFb7WRAoIqKxBVij9L3pBQmV1O6N/Ml G1hGiXPjCNEsppHrKu/+MlY279l7+IAKzsq5FPUln/mXlzsgiDo6r4rNz7mXvISimIeL kDduyY8qITsassA6hN3ZS8PFVqLs9G/n70CGI1IeBucgJ/3qm+HovNqHfQf5QDkU/Okz d8Qj/PDyRRk52M8jlaYy0QccOiI1Z0NWQiOgxVnocKrokp4d3Zq0Iz5n8sHHtGyw4zKh ZeeA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ao9g58MR; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-127162-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127162-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m18-20020a170902c45200b001e00e16b003si9667574plm.413.2024.04.01.16.22.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 16:22:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127162-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ao9g58MR; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-127162-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127162-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 30ED1B20D43 for ; Mon, 1 Apr 2024 23:22:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 212C156B9D; Mon, 1 Apr 2024 23:21:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ao9g58MR" Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (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 CC16543AD1; Mon, 1 Apr 2024 23:21:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712013718; cv=none; b=hESNNkMOtPbWU1YMJWUK6x6gJVo294ai6mliaYF+joHEln7Mj+kHNgI0ciqWACJYrJoVk63xvjJ+CY/95YngSIqRYmQZmTFsyIF+I/oRTdiZNiCGaDPb17m+MzHiRrweASXrYOv6hbU9s73z9HVu8uKgLZvwxNKdcNjK+WH8dYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712013718; c=relaxed/simple; bh=0+EAJqjhy7qUnqyXbEMpjBscGPZgEX2cmg4eE/DdrxI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=iiKtwaJ9Z6wq2LOcdbSqYpkvFHIdIcMz0ukQtVggs02o3sGLBVGzb/grPUS8NNUkAUYARb2oRTEkmfAHxXs+ghjlRSH5ouygArhlz0wgDzojBWBhzzfr8ZjqG2ie9bYotAP7nKBdByM9bCHuWJ5TDG+8SZ3H2LgKMjFgEYMy/B8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ao9g58MR; arc=none smtp.client-ip=209.85.128.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-61428e80f0cso22866617b3.2; Mon, 01 Apr 2024 16:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712013716; x=1712618516; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=D1mxLt9IrQqWthikg7YY8D2OyqeJAzfgA0Sf3WwzMsM=; b=ao9g58MR/JpSP/MIw/Mgreb1c5HO30aULOS4k6PU8/kUpV7TZGavJh8/cynwQw7Zwa pUKS2men6c0Q+M+fCKxbMAfk/b85G0NTukLGsxFvBpQ1LLaW8nl6uB40ojK+eJhoxmsF DQ2TIhFs3LR4oj5Hk8zDrNiqIGHCtNQWaOEqp9NbDo87/ygkqh1IHywHblDhYmPBWQsF yj3nDDCdsT27cmMOdlwpbZBDL7a8L8Jtlp/4hafVj/kZtVq/wslBl1z9l5gv3xpfRzW9 e0cRVcqoTpfvSFCDFlUJjEqQf0ib0UNfOdCHKOsp4KOrqA14QRilOa09LOBnskSAIGFx 0LTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712013716; x=1712618516; h=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=D1mxLt9IrQqWthikg7YY8D2OyqeJAzfgA0Sf3WwzMsM=; b=ubIsUyKCTgXPqJXSPrE47IxJUNIrzAiHB1yaCToMisHen+djt3MiB297xbE1Jyb17j 31I3Cd5iTCvx/yiGqFNwSlE0trGylCeGLYoo57TK+5yFEBvm/VrYRf4OYicuBtCiRBT6 40pfRpPERAz/kJzEmZsbzSlqRiwc8clfhOrv3VDPE9F1Swx1oHDbB6VhpSm06N706rHj y13VrJQxSoEtKrhI4T6OkhrZyu2oSLjZssrh/29S616ArJ6twz5FRo15R06MMawPzDxL 1T8M9mPO/Qx1NR0up9pMZAS9YyUilzqSmd9QJJs0Vsue7rXfwRfSIwZdbJXU4QfifD1Z dC9A== X-Forwarded-Encrypted: i=1; AJvYcCWMcPPfEnoeMmk1mYq5PNuOQKhGW3ypdGCgqDmzonxi4I7vr1rBo/E29Ef/S8PS1T+UF6DiiXx8d+27KWXEaLjVnfPKG9nfrufAoIjp X-Gm-Message-State: AOJu0Yx+I8gZy0ofPHQGk43Dd3ZUY9jaz5zMnRQYDaXqiC2LS2n926XP siBV7yJNIinPiEcLkb5B1XVJbfkpJMAb9z0Zb49PpbS5T/BGW+i8CRRkdbjmy5tw2JiffTIkjwX /g+/p+EGXhtOHbhZMIWhkv5maGn7chTLzomg= X-Received: by 2002:a05:690c:4482:b0:615:1294:d6b0 with SMTP id gr2-20020a05690c448200b006151294d6b0mr1683623ywb.25.1712013715655; Mon, 01 Apr 2024 16:21:55 -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: Wedson Almeida Filho Date: Mon, 1 Apr 2024 20:21:45 -0300 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 , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Martin Rodriguez Reboredo , Obei Sideg Content-Type: text/plain; charset="UTF-8" On Mon, 1 Apr 2024 at 18:46, Boqun Feng wrote: > > To support a potential usage: > > static foo: Opaque = ..; // Or defined in an extern block. > > ... > > fn bar() { > let ptr = 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: Wedson Almeida Filho