-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Don't lint indexing_slicing lints on proc macros #12912
Conversation
18c133d
to
1b667aa
Compare
clippy_lints/src/indexing_slicing.rs
Outdated
@@ -126,6 +126,10 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing { | |||
return; | |||
}; | |||
|
|||
if is_from_proc_macro(cx, expr) { |
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.
Can we have this check earlier in check_expr
?
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.
Yes, for sure! I thought that it would be better to postpone to the lastest moment, because this check is "heavy", but probably I misunderstood it :)
I will do the change!
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.
@dswij done. I have moved it to the very beginning of the function. Because of that, now we can have just one check instead of 4. Commit was amended.
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! Thank you for the PR and addressing the comments.
@bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This pr fixes #12824
Even though the issue mentions the indexing case only, it was easy to apply the fix to the slicing case as well.
changelog: [
out_of_bounds_indexing
,indexing_slicing
]: Don't lint on procedural macros.