Skip to content

Commit e10ebef

Browse files
committed
Rename thread_local_initializer_can_be_made_const to missing_const_for_tl_init
1 parent 7a79fea commit e10ebef

File tree

6 files changed

+83
-73
lines changed

6 files changed

+83
-73
lines changed

clippy_config/src/msrvs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ msrv_aliases! {
2525
1,65,0 { LET_ELSE, POINTER_CAST_CONSTNESS }
2626
1,63,0 { CLONE_INTO }
2727
1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE }
28-
1,59,0 { THREAD_LOCAL_INITIALIZER_CAN_BE_MADE_CONST }
28+
1,59,0 { MISSING_CONST_FOR_TL_INIT }
2929
1,58,0 { FORMAT_ARGS_CAPTURE, PATTERN_TRAIT_CHAR_ARRAY, CONST_RAW_PTR_DEREF }
3030
1,56,0 { CONST_FN_UNION }
3131
1,55,0 { SEEK_REWIND }

clippy_lints/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,9 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
11501150
})
11511151
});
11521152
store.register_late_pass(move |_| {
1153-
Box::new(missing_const_for_tl_init::ThreadLocalInitializerCanBeMadeConst::new(msrv()))
1153+
Box::new(missing_const_for_tl_init::MissingConstForTlInit::new(
1154+
msrv(),
1155+
))
11541156
});
11551157
store.register_late_pass(move |_| Box::new(incompatible_msrv::IncompatibleMsrv::new(msrv())));
11561158
store.register_late_pass(|_| Box::new(to_string_trait_impl::ToStringTraitImpl));

clippy_lints/src/missing_const_for_tl_init.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ declare_clippy_lint! {
4444
"suggest using `const` in `thread_local!` macro"
4545
}
4646

47-
pub struct ThreadLocalInitializerCanBeMadeConst {
47+
pub struct MissingConstForTlInit {
4848
msrv: Msrv,
4949
}
5050

51-
impl ThreadLocalInitializerCanBeMadeConst {
51+
impl MissingConstForTlInit {
5252
#[must_use]
5353
pub fn new(msrv: Msrv) -> Self {
5454
Self { msrv }
5555
}
5656
}
5757

58-
impl_lint_pass!(ThreadLocalInitializerCanBeMadeConst => [MISSING_CONST_FOR_TL_INIT]);
58+
impl_lint_pass!(MissingConstForTlInit => [MISSING_CONST_FOR_TL_INIT]);
5959

6060
#[inline]
6161
fn is_thread_local_initializer(
@@ -102,7 +102,7 @@ fn initializer_can_be_made_const(cx: &LateContext<'_>, defid: rustc_span::def_id
102102
false
103103
}
104104

105-
impl<'tcx> LateLintPass<'tcx> for ThreadLocalInitializerCanBeMadeConst {
105+
impl<'tcx> LateLintPass<'tcx> for MissingConstForTlInit {
106106
fn check_fn(
107107
&mut self,
108108
cx: &LateContext<'tcx>,

tests/ui/missing_const_for_tl_init.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
error: initializer for `thread_local` value can be made `const`
2-
--> tests/ui/thread_local_initializer_can_be_made_const.rs:8:41
2+
--> tests/ui/missing_const_for_tl_init.rs:8:41
33
|
44
LL | static BUF_1: RefCell<String> = RefCell::new(String::new());
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(String::new()) }`
66
|
7-
= note: `-D clippy::thread-local-initializer-can-be-made-const` implied by `-D warnings`
8-
= help: to override `-D warnings` add `#[allow(clippy::thread_local_initializer_can_be_made_const)]`
7+
= note: `-D clippy::missing-const-for-tl-init` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::missing_const_for_tl_init)]`
99

1010
error: initializer for `thread_local` value can be made `const`
11-
--> tests/ui/thread_local_initializer_can_be_made_const.rs:18:29
11+
--> tests/ui/missing_const_for_tl_init.rs:18:29
1212
|
1313
LL | static SIMPLE:i32 = 1;
1414
| ^ help: replace with: `const { 1 }`
1515

1616
error: initializer for `thread_local` value can be made `const`
17-
--> tests/ui/thread_local_initializer_can_be_made_const.rs:24:59
17+
--> tests/ui/missing_const_for_tl_init.rs:24:59
1818
|
1919
LL | static BUF_3_CAN_BE_MADE_CONST: RefCell<String> = RefCell::new(String::new());
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(String::new()) }`
2121

2222
error: initializer for `thread_local` value can be made `const`
23-
--> tests/ui/thread_local_initializer_can_be_made_const.rs:26:59
23+
--> tests/ui/missing_const_for_tl_init.rs:26:59
2424
|
2525
LL | static BUF_4_CAN_BE_MADE_CONST: RefCell<String> = RefCell::new(String::new());
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(String::new()) }`
2727

2828
error: initializer for `thread_local` value can be made `const`
29-
--> tests/ui/thread_local_initializer_can_be_made_const.rs:32:31
29+
--> tests/ui/missing_const_for_tl_init.rs:32:31
3030
|
3131
LL | static PEEL_ME: i32 = { 1 };
3232
| ^^^^^ help: replace with: `const { 1 }`
3333

3434
error: initializer for `thread_local` value can be made `const`
35-
--> tests/ui/thread_local_initializer_can_be_made_const.rs:34:36
35+
--> tests/ui/missing_const_for_tl_init.rs:34:36
3636
|
3737
LL | static PEEL_ME_MANY: i32 = { let x = 1; x * x };
3838
| ^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { { let x = 1; x * x } }`

tests/ui/rename.fixed

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#![allow(clippy::needless_borrow)]
2828
#![allow(clippy::single_char_add_str)]
2929
#![allow(clippy::module_name_repetitions)]
30+
#![allow(clippy::missing_const_for_tl_init)]
3031
#![allow(clippy::recursive_format_impl)]
3132
#![allow(clippy::unwrap_or_default)]
3233
#![allow(clippy::invisible_characters)]
@@ -83,6 +84,7 @@
8384
#![warn(clippy::unwrap_used)]
8485
#![warn(clippy::single_char_add_str)]
8586
#![warn(clippy::module_name_repetitions)]
87+
#![warn(clippy::missing_const_for_tl_init)]
8688
#![warn(clippy::recursive_format_impl)]
8789
#![warn(clippy::unwrap_or_default)]
8890
#![warn(clippy::invisible_characters)]

0 commit comments

Comments
 (0)