-
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
Disable arithmetic lints in constant items #3331
Conversation
This won't catch array lengths. You can get them the easiest by having an impl of I think you should name the |
bc845c2
to
7dea4dc
Compare
I changed the name and added a doc comment. There doesn't seem to be any similar method to |
7dea4dc
to
25d63c8
Compare
@oli-obk I've rewritten the checks to use |
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.
r=me with nit fixed
clippy_lints/src/arithmetic.rs
Outdated
fn check_body(&mut self, cx: &LateContext<'_, '_>, body: &hir::Body) { | ||
let body_owner = cx.tcx.hir.body_owner(body.id()); | ||
|
||
if let hir::BodyOwnerKind::Fn = cx.tcx.hir.body_owner_kind(body_owner) { |
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 you change this to !=
instead of having an empty arm on if let
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.
or do an exhaustive match on all BodyOwnerKind
variants so future changes don't trip us up
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.
Fixed.
25d63c8
to
0b9e9c9
Compare
bors r=oli-obk |
👎 Rejected by code reviews |
bors r+ weird... feel free to dismiss my reviews in such situations |
3331: Disable arithmetic lints in constant items r=oli-obk a=pengowen123 Currently this will not catch cases in associated constants. I'm not sure whether checking spans is the best way to solve this issue, but I don't think it will cause any problems. Fixes #1858 Co-authored-by: Owen Sanchez <[email protected]>
Currently this will not catch cases in associated constants. I'm not sure whether checking spans is the best way to solve this issue, but I don't think it will cause any problems.
Fixes #1858