-
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
Some accuracy lints for floating point operations #5443
Conversation
LGTM. Please read up in #4897 on the discussion of naming these lints and which lint should apply to which float expression. |
I'll make a note to review which lints goes into About naming, I assume I'm ok if I stick to those two names? |
You can just put the different cases where you think they fit best (and note that in the PR body for easier review please). The names SGTM. |
I'm trying to make Any tips on how to avoid that? Should I change the mul_add lint to skip that case? |
I think making |
Still working on this. Quick question: how do you folks usually deal with cross lint errors? I've got a problem because the lint for |
If a lint suggests code that again gets linted by another lint, that is not a problem. Only if 2 lints trigger on the same code simultaneously is a problem. In those cases one lint should take preference. |
Should I do anything differently here, then? I'm getting the error below when I run
|
Just allow the other lint in this test file (or just for this test case). |
12befdd
to
149c3ea
Compare
FYI: since this is a big PR, which seems to be under active development, I won't review every change here (At least as long as there is WIP in the title). @thiagoarrais if you have questions or want to have a review anyway, feel free to ask anytime though. |
No problem! Thanks for the feedback! |
9a77544
to
237309b
Compare
I'm removing the WIP marker as this is ready for review. Some of the proposed lints were already covered in master:
And here is a summary of which lint went into each group. It wasn't really clear to me what should go where. Please let me know if any of these are in the wrong drawer.
|
Since x.log(y) is actually implemented as x.ln() / y.ln()
Added |
@bors r+ |
📌 Commit 3065201 has been approved by |
Some accuracy lints for floating point operations This will add some lints for accuracy on floating point operations suggested by @clarfon in #2040 (fixes #2040). These are the remaining lints: - [x] x.powi(2) => x * x - [x] x.logN() / y.logN() => x.logbase(y) - [x] x.logbase(E) => x.log() - [x] x.logbase(10) => x.log10() - [x] x.logbase(2) => x.log2(). - [x] x * PI / 180 => x.to_radians() - [x] x * 180 / PI => x.to_degrees() - [x] (x + 1).log() => x.log_1p() - [x] sqrt(x * x + y * y) => x.hypot(y) changelog: Included some accuracy lints for floating point operations
@bors rollup=iffy |
@bors retry (yeet) |
Some accuracy lints for floating point operations This will add some lints for accuracy on floating point operations suggested by @clarfon in rust-lang#2040 (fixes rust-lang#2040). These are the remaining lints: - [x] x.powi(2) => x * x - [x] x.logN() / y.logN() => x.logbase(y) - [x] x.logbase(E) => x.log() - [x] x.logbase(10) => x.log10() - [x] x.logbase(2) => x.log2(). - [x] x * PI / 180 => x.to_radians() - [x] x * 180 / PI => x.to_degrees() - [x] (x + 1).log() => x.log_1p() - [x] sqrt(x * x + y * y) => x.hypot(y) changelog: Included some accuracy lints for floating point operations
Some accuracy lints for floating point operations This will add some lints for accuracy on floating point operations suggested by @clarfon in #2040 (fixes #2040). These are the remaining lints: - [x] x.powi(2) => x * x - [x] x.logN() / y.logN() => x.logbase(y) - [x] x.logbase(E) => x.log() - [x] x.logbase(10) => x.log10() - [x] x.logbase(2) => x.log2(). - [x] x * PI / 180 => x.to_radians() - [x] x * 180 / PI => x.to_degrees() - [x] (x + 1).log() => x.log_1p() - [x] sqrt(x * x + y * y) => x.hypot(y) changelog: Included some accuracy lints for floating point operations
@bors retry (yeet yeet) |
Rollup of 5 pull requests Successful merges: - #5443 (Some accuracy lints for floating point operations) - #5752 (Move range_minus_one to pedantic) - #5756 (unnecessary_sort_by: avoid linting if key borrows) - #5784 (Fix out of bounds access by checking length equality BEFORE accessing by index.) - #5786 (fix phrase in new_lint issue template) Failed merges: r? @ghost changelog: rollup
☔ The latest upstream changes (presumably #5792) made this pull request unmergeable. Please resolve the merge conflicts. |
This will add some lints for accuracy on floating point operations suggested by @clarfon in #2040 (fixes #2040).
These are the remaining lints:
changelog: Included some accuracy lints for floating point operations