From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ronja.mits.lan by ronja.mits.lan with LMTP id IKbNDC8NfGY6GgAAxxbTJA (envelope-from ); Wed, 26 Jun 2024 14:44:31 +0200 Received: from proxmox-new.maurer-it.com (unknown [192.168.2.33]) by ronja.mits.lan (Postfix) with ESMTPS id 207BDF6463A; Wed, 26 Jun 2024 14:44:31 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 0658242D92; Wed, 26 Jun 2024 14:44:31 +0200 (CEST) Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by proxmox-new.maurer-it.com (Proxmox) with ESMTPS; Wed, 26 Jun 2024 14:44:30 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CB11BE66; Wed, 26 Jun 2024 14:44:29 +0200 (CEST) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Wed, 26 Jun 2024 14:43:36 +0200 Message-Id: <20240626124346.531790-8-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626124346.531790-1-m.sandoval@proxmox.com> References: <20240626124346.531790-1-m.sandoval@proxmox.com> MIME-Version: 1.0 Subject: [pbs-devel] [PATCH proxmox v2 08/18] use const blocks in thread_local! calls X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" X-SPAM-LEVEL: Spam detection results: 0 DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods MAILING_LIST_MULTI -2 Multiple indicators imply a widely-seen list manager RAZOR2_CF_RANGE_51_100 2.43 Razor2 gives confidence level above 50% RAZOR2_CHECK 1.729 Listed in Razor2 (http://razor.sf.net/) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Fixes the clippy warning: warning: initializer for `thread_local` value can be made `const` --> proxmox-router/src/cli/command.rs:221:71 | 221 | static HELP_CONTEXT: RefCell>> = RefCell::new(None); | ^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(None) }` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#thread_local_initializer_can_be_made_const = note: `#[warn(clippy::thread_local_initializer_can_be_made_const)]` on by default Signed-off-by: Maximiliano Sandoval --- proxmox-api-macro/src/lib.rs | 2 +- proxmox-router/src/cli/command.rs | 2 +- proxmox-schema/src/de/mod.rs | 2 +- proxmox-schema/src/de/verify.rs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/proxmox-api-macro/src/lib.rs b/proxmox-api-macro/src/lib.rs index 9888b76c..3c34b48b 100644 --- a/proxmox-api-macro/src/lib.rs +++ b/proxmox-api-macro/src/lib.rs @@ -313,7 +313,7 @@ pub fn derive_updater_type(item: TokenStream_1) -> TokenStream_1 { .into() } -thread_local!(static NON_FATAL_ERRORS: RefCell> = RefCell::new(None)); +thread_local!(static NON_FATAL_ERRORS: RefCell> = const { RefCell::new(None) }); /// The local error TLS must be freed at the end of a macro as any leftover `TokenStream` (even an /// empty one) will just panic between different runs as the multiple source files are handled by diff --git a/proxmox-router/src/cli/command.rs b/proxmox-router/src/cli/command.rs index a97c9d48..fca05e32 100644 --- a/proxmox-router/src/cli/command.rs +++ b/proxmox-router/src/cli/command.rs @@ -218,7 +218,7 @@ const API_METHOD_COMMAND_HELP: ApiMethod = ApiMethod::new( ); std::thread_local! { - static HELP_CONTEXT: RefCell>> = RefCell::new(None); + static HELP_CONTEXT: RefCell>> = const { RefCell::new(None) }; } fn help_command( diff --git a/proxmox-schema/src/de/mod.rs b/proxmox-schema/src/de/mod.rs index 09ccfeb3..79fb18e7 100644 --- a/proxmox-schema/src/de/mod.rs +++ b/proxmox-schema/src/de/mod.rs @@ -24,7 +24,7 @@ pub use no_schema::{split_list, SplitList}; // Used to disable calling `check_constraints` on a `StringSchema` if it is being deserialized // for a `PropertyString`, which performs its own checking. thread_local! { - static IN_PROPERTY_STRING: Cell = Cell::new(false); + static IN_PROPERTY_STRING: Cell = const { Cell::new(false) }; } pub(crate) struct InPropertyStringGuard; diff --git a/proxmox-schema/src/de/verify.rs b/proxmox-schema/src/de/verify.rs index 24a14772..615e69cf 100644 --- a/proxmox-schema/src/de/verify.rs +++ b/proxmox-schema/src/de/verify.rs @@ -16,8 +16,8 @@ struct VerifyState { } thread_local! { - static VERIFY_SCHEMA: RefCell> = RefCell::new(None); - static ERRORS: RefCell> = RefCell::new(Vec::new()); + static VERIFY_SCHEMA: RefCell> = const { RefCell::new(None) }; + static ERRORS: RefCell> = const { RefCell::new(Vec::new()) }; } pub(crate) struct SchemaGuard(Option); -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel