-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Threadlocal_initializer_can_be_made_const will not trigger for unreachable initializers #12685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I've made a new patch that does a few things: |
…hable initializers This commit introduces a check to ensure that the lint won't trigger when the initializer is unreachable, such as: ``` thread_local! { static STATE: Cell<usize> = panic!(); } ``` This is achieved by looking at the unpeeled initializer expression and ensuring that the parent macro is not `panic!()`, `todo!()`, `unreachable!()`, `unimplemented!()`. fixes #12637 changelog: [`threadlocal_initializer_can_be_made_const`] will no longer trigger on `unreachable` macros.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! ❤️
I've done a little change (optimization + symbols directly)
@bors r+ |
This pattern seems to happen pretty often. |
Threadlocal_initializer_can_be_made_const will not trigger for unreachable initializers This commit introduces a check to ensure that the lint won't trigger when the initializer is unreachable, such as: ``` thread_local! { static STATE: Cell<usize> = panic!(); } ``` This is achieved by looking at the unpeeled initializer expression and ensuring that the parent macro is not `panic!()`, `todo!()`, `unreachable!()`, `unimplemented!()`. fixes #12637 changelog: [`threadlocal_initializer_can_be_made_const`] will no longer trigger on `unreachable` macros.
@bors r- |
Hmmmm... lemme see where else is this pattern used (meow) |
☀️ Try build successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Where else is some kind of function like this used? I've tried to Ctrl+Shift+F but there doesn't seem to exist almost anywhere else (and be extrapolatable) |
Off the top of my head; In |
Hmmm... If there are at least two others and you're feeling extra-helpful today, yeah it would help! ❤️ |
@bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This commit introduces a check to ensure that the lint won't trigger when the initializer is unreachable, such as:
This is achieved by looking at the unpeeled initializer expression and ensuring that the parent macro is not
panic!()
,todo!()
,unreachable!()
,unimplemented!()
.fixes #12637
changelog: [
threadlocal_initializer_can_be_made_const
] will no longer trigger onunreachable
macros.