mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 00:47:16 +00:00
Auto merge of #12405 - PartiallyTyped:12404, r=blyxyas
Added msrv to threadlocal initializer check closes: #12404 changelog:[`thread_local_initializer_can_be_made_const`]: Check for MSRV (>= 1.59) before processing.
This commit is contained in:
commit
aceeb54b75
4 changed files with 18 additions and 2 deletions
|
@ -24,6 +24,7 @@ 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 @@ impl<'tcx> LateLintPass<'tcx> for ThreadLocalInitializerCanBeMadeConst {
|
|||
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 a new issue