Skip to content
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

Rollup of 5 pull requests #5792

Merged
merged 21 commits into from
Jul 13, 2020
Merged

Rollup of 5 pull requests #5792

merged 21 commits into from
Jul 13, 2020

Conversation

flip1995
Copy link
Member

@flip1995 flip1995 commented Jul 13, 2020

Successful merges:

Failed merges:

r? @ghost

changelog: rollup

thiagoarrais and others added 21 commits July 6, 2020 13:23
Since x.log(y) is actually implemented as x.ln() / y.ln()
This moves the range_minus_one lint to the pedantic category, so there
will not be any warnings emitted by default. This should work around
problems where the suggestion is impossible to resolve due to the range
consumer only accepting a specific range implementation, rather than the
`RangeBounds` trait (see rust-lang#3307).

While it is possible to work around this by extracting the boundary into
a variable, I don't think clippy should encourage people to disable or
work around lints, but instead the lints should be fixable. So hopefully
this will help until a proper implementation checks what the range is
used for.
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
Move range_minus_one to pedantic

This moves the range_minus_one lint to the pedantic category, so there
will not be any warnings emitted by default. This should work around
problems where the suggestion is impossible to resolve due to the range
consumer only accepting a specific range implementation, rather than the
`RangeBounds` trait (see rust-lang#3307).

While it is possible to work around this by extracting the boundary into
a variable, I don't think clippy should encourage people to disable or
work around lints, but instead the lints should be fixable. So hopefully
this will help until a proper implementation checks what the range is
used for.

*Please keep the line below*
changelog: move [`range_minus_one`] to pedantic
unnecessary_sort_by: avoid linting if key borrows

changelog: Avoid linting if key borrows in [`unnecessary_sort_by`]

Fixes rust-lang#5754
Closes rust-lang#2313
Fix out of bounds access by checking length equality BEFORE accessing by index.

Fixes rust-lang#5780

changelog: fix out of bounds access in unnested_or_patterns lint.

Edit: I did not bother reducing a testcase from `librustc_typeck` crate but I can confirm that with the change the crash no longer occurs.
…=phansch

fix phrase in new_lint issue template

changelog: none
@flip1995
Copy link
Member Author

@bors p=5

@flip1995
Copy link
Member Author

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 13, 2020

📌 Commit 314b068 has been approved by flip1995

@bors
Copy link
Collaborator

bors commented Jul 13, 2020

⌛ Testing commit 314b068 with merge 4b87008...

@bors
Copy link
Collaborator

bors commented Jul 13, 2020

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing 4b87008 to master...

@bors bors merged commit 4b87008 into rust-lang:master Jul 13, 2020
@flip1995 flip1995 deleted the rollup-torc1we branch July 13, 2020 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants