From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox v2 08/18] use const blocks in thread_local! calls
Date: Wed, 26 Jun 2024 14:43:36 +0200 [thread overview]
Message-ID: <20240626124346.531790-8-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20240626124346.531790-1-m.sandoval@proxmox.com>
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<Option<Arc<CommandLineInterface>>> = 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 <m.sandoval@proxmox.com>
---
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<Option<TokenStream>> = RefCell::new(None));
+thread_local!(static NON_FATAL_ERRORS: RefCell<Option<TokenStream>> = 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<Option<Arc<CommandLineInterface>>> = RefCell::new(None);
+ static HELP_CONTEXT: RefCell<Option<Arc<CommandLineInterface>>> = 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<bool> = Cell::new(false);
+ static IN_PROPERTY_STRING: Cell<bool> = 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<Option<VerifyState>> = RefCell::new(None);
- static ERRORS: RefCell<Vec<(String, anyhow::Error)>> = RefCell::new(Vec::new());
+ static VERIFY_SCHEMA: RefCell<Option<VerifyState>> = const { RefCell::new(None) };
+ static ERRORS: RefCell<Vec<(String, anyhow::Error)>> = const { RefCell::new(Vec::new()) };
}
pub(crate) struct SchemaGuard(Option<VerifyState>);
--
2.39.2
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2024-06-26 12:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 02/18] use contains_key instead of .get().is_{some, none}() Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 03/18] remove needless borrows Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 04/18] remove unnecesary pub(self) Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 05/18] time-api: remove redundant field names Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 06/18] acme: remove duplicated attribute Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 07/18] acl: remove null pointer cast Maximiliano Sandoval
2024-06-26 12:43 ` Maximiliano Sandoval [this message]
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 09/18] remove unneeded returns Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 10/18] shared-memory: remove unneeded generic parameter Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 11/18] network-api: remove useless uses of format! Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 12/18] http: remove redundant redefinition of binding Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 13/18] http: remove unnecessary cast Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 14/18] acme: elide explicit lifetimes Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 15/18] acme: derive Default for Status Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 16/18] acl: directly return struct rather than a binding Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 17/18] acme-api: remove manual implementation of Option::map Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 18/18] auth-api: do not clone struct implementing Copy Maximiliano Sandoval
2024-06-28 9:44 ` [pbs-devel] applied-series: [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240626124346.531790-8-m.sandoval@proxmox.com \
--to=m.sandoval@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox