Added msrv to threadlocal initializer
This commit is contained in:
parent
28e11b31de
commit
08459b4dae
@ -24,6 +24,7 @@ macro_rules! msrv_aliases {
|
||||
1,68,0 { PATH_MAIN_SEPARATOR_STR }
|
||||
1,65,0 { LET_ELSE, POINTER_CAST_CONSTNESS }
|
||||
1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE }
|
||||
1,59,0 { THREAD_LOCAL_INITIALIZER_CAN_BE_MADE_CONST }
|
||||
1,58,0 { FORMAT_ARGS_CAPTURE, PATTERN_TRAIT_CHAR_ARRAY }
|
||||
1,55,0 { SEEK_REWIND }
|
||||
1,54,0 { INTO_KEYS }
|
||||
|
@ -1,4 +1,4 @@
|
||||
use clippy_config::msrvs::Msrv;
|
||||
use clippy_config::msrvs::{self, Msrv};
|
||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::qualify_min_const_fn::is_min_const_fn;
|
||||
use clippy_utils::source::snippet;
|
||||
@ -92,7 +92,8 @@ fn check_fn(
|
||||
local_defid: rustc_span::def_id::LocalDefId,
|
||||
) {
|
||||
let defid = local_defid.to_def_id();
|
||||
if is_thread_local_initializer(cx, fn_kind, span).unwrap_or(false)
|
||||
if self.msrv.meets(msrvs::THREAD_LOCAL_INITIALIZER_CAN_BE_MADE_CONST)
|
||||
&& is_thread_local_initializer(cx, fn_kind, span).unwrap_or(false)
|
||||
// Some implementations of `thread_local!` include an initializer fn.
|
||||
// In the case of a const initializer, the init fn is also const,
|
||||
// so we can skip the lint in that case. This occurs only on some
|
||||
|
@ -35,3 +35,10 @@ fn main() {
|
||||
//~^ ERROR: initializer for `thread_local` value can be made `const`
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.58"]
|
||||
fn f() {
|
||||
thread_local! {
|
||||
static TLS: i32 = 1;
|
||||
}
|
||||
}
|
||||
|
@ -35,3 +35,10 @@ fn main() {
|
||||
//~^ ERROR: initializer for `thread_local` value can be made `const`
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.58"]
|
||||
fn f() {
|
||||
thread_local! {
|
||||
static TLS: i32 = 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user