-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Implement lint for regex::Regex compilation inside a loop #13412
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @y21 (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
63c6dac
to
711fd7f
Compare
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.
I started reviewing this 2 days ago but then forgot to continue 😅 Overall looks great aside from a few things
Given regex's own advice it makes me wonder if we could just have a lint for regex creations with literals outside of a static anywhere as having it in a static with LazyLock would avoid recompiling it ever again even across function calls, but I can see how that's more... controversial than just this specific pattern |
Yeah, that would be a separate (pedantic) lint should probably have an issue opened for it, but definitely not this one. |
711fd7f
to
9f5bfe2
Compare
FCP thread for the lint: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/FCP.3A.20regex_creation_in_loops |
d67aa68
to
196dbcf
Compare
Looks all good now, thank you for working on this lint! @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Closes #598.
Seems like a pretty simple one, I'm not sure if I sorted out all the lint plumbing correctly because I was adding it to the existing regex pass, but seems to work. The name is a bit jank and I'm super open to suggestions for changing it.
changelog: [
regex_creation_in_loops
]: Added lint for Regex compilation inside loops.