use const blocks in thread_local! calls
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>
This commit is contained in:
parent
e3602c1943
commit
d07a0243f4
@ -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
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
|
@ -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>);
|
||||
|
Loading…
Reference in New Issue
Block a user